473,382 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

hashtable...squid

s88
I work with the bit-vector(http://search.cpan.org/dist/Bit-Vector/)
and squid lib as well. But I meet a weird situation now...Let's see my
code.
I wanna creat a hashtable in a function, and then return the address of
the hashtable.
But my hashtable looks empty outside the fake_table().
The hashtable just manage the pointer I insert. Don't really "copy"
anything into the table.
hashtable *fake_table(){

BitVector_Boot();
N_char x1[] = "101000";
N_char x2[] = "101010";

wordptr X1 = BitVector_Create(6, 1);
wordptr X2 = BitVector_Create(6, 1);

BitVector_from_Bin(X1, x1);
BitVector_from_Bin(X2, x2);

hash_table *inst_table =
hash_create(inst_tb_compare,7951,hash_string);
hash_table *ht2 =
hash_create(inst_tb_compare,7951,hash_string);

inst_tb_atom *_atom1 = (inst_tb_atom
*)malloc(sizeof(inst_tb_atom));
inst_tb_atom *_atom2 = (inst_tb_atom
*)malloc(sizeof(inst_tb_atom));

_atom1->_type = 1;
_atom1->point_to.ht = ht2;
_atom1->X = X1;

_atom2->_type = 1;
_atom2->point_to.ht = ht3;
_atom2->X = X2;

hash_insert(ht2,x2,_atom2);
hash_insert(inst_table,x1,_atom1);

return inst_table;
}

Thanx!!!

Nov 14 '05 #1
1 1709
On 30 May 2005 17:45:29 -0700, "s88" <da*****@gmail.com> wrote in
comp.lang.c:
I work with the bit-vector(http://search.cpan.org/dist/Bit-Vector/)
and squid lib as well. But I meet a weird situation now...Let's see my
code.
I wanna creat a hashtable in a function, and then return the address of
the hashtable.
But my hashtable looks empty outside the fake_table().
The hashtable just manage the pointer I insert. Don't really "copy"
anything into the table.
The problem here is that your code is littered with non-standard types
that are apparently defined (with typedef or macros) in the header
files for the third party libraries that you are trying to use.
hashtable *fake_table(){

BitVector_Boot();
The C language does not define what this function call does, so there
is no reason at all to assume that anyone here knows either.
N_char x1[] = "101000";
N_char x2[] = "101010";
Here you appear to be defining two arrays of type 'N_char', which must
be an alias for one of the character types, after calling a function.
Does your compiler conform to the 1999 or later version of the C
standard? This is illegal code in earlier versions of C.

wordptr X1 = BitVector_Create(6, 1);
wordptr X2 = BitVector_Create(6, 1);

BitVector_from_Bin(X1, x1);
BitVector_from_Bin(X2, x2);

hash_table *inst_table =
hash_create(inst_tb_compare,7951,hash_string);
hash_table *ht2 =
hash_create(inst_tb_compare,7951,hash_string);

inst_tb_atom *_atom1 = (inst_tb_atom
*)malloc(sizeof(inst_tb_atom));
Casting the pointer returned by malloc() in C is unnecessary and can
hide a serious error causing undefined behavior if <stdlib.h> is not
included or there is otherwise not a proper prototype for malloc() in
scope.

Also you are committing the serious error of not checking the return
value of malloc() for NULL, which it will return if the allocation
fails.

inst_tb_atom *_atom2 = (inst_tb_atom
*)malloc(sizeof(inst_tb_atom));

_atom1->_type = 1;
_atom1->point_to.ht = ht2;
_atom1->X = X1;

_atom2->_type = 1;
_atom2->point_to.ht = ht3;
_atom2->X = X2;

hash_insert(ht2,x2,_atom2);
hash_insert(inst_table,x1,_atom1);

return inst_table;
}

Thanx!!!


We haven't got the faintest idea of how these functions get the memory
they use. You'll have to talk to whoever made the library.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leonardo Ivan Torres Ochoa | last post by:
Hello friends I have a program client done in C # that invokes to a Web service, the program client uses proxy squid, but this return Timeout returns Any idea ? Thank you .. Leonardo..
0
by: .NET Undertaker | last post by:
Hi I have windows application(C#) that consumes a Web Service.Now my problem is with clients whom installed my application and use SQUId 2.5/Stable 4 , they keep getting HTTP error 407 proxy...
0
by: phil.a.jenkins | last post by:
Hopefully someone can provide a solution to this rather annoying problem - we have a Cocoon pipeline which ends thus: <!-- build the sql for insert and final stage of select --> T1 ...
0
by: Marcus Ogden | last post by:
Hello, A client of ours using the Squid proxy server (version 2.5.STABLE6-3.4E.12.1) on Red Hat Enterprise Linux 4 is experiencing a problem when running our .NET 2.0 client application, which...
1
by: ntech | last post by:
hello, Before, i run the squid in my system, the CPU is almost idle but as soon a run the squid, the CPU consumes 99% of the system. so i don't understand the problem. i have even rotated the squid...
1
by: karthikeyanck | last post by:
I 've installed squid proxy server on my Ubuntu machine (Vmware image) It has no direct internet connection and is on a private n/w (192.168). It uses another proxy server to reach the internet....
1
sokoun
by: sokoun | last post by:
Hi all, could anybody help me to correct this problem, i used squid 2.6 as transparent proxy. when i browse to that server i got an error: The requested URL could not be retrieved While...
1
sokoun
by: sokoun | last post by:
All, Could anyone help me to resolve this problem? I used putty for ssh tunnelling from window to linux server, and i used squid as the proxy server. I want to redirect the traffic from the ssh...
6
by: Larry Hale | last post by:
Greetings, Pythonistas! My employer has a Squid Proxy between my Python programs and The Internet. I've searched high-and-low, and can only find examples online of how to do basic...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.