KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i'm breaking my head for hours on the following problem: i pasted 2 functions althought there are many more. i run valgrind on my program and i get 32 errors similar to this: ==4214== 6 errors in context 8 of 10: ==4214== Conditional jump or move depends on uninitialised value(s) ==4214== at 0x40088F: getNextFreeCell (in /a/fr-01/vol/home/stud/ashers03/c/ex4/test) ==4214== by 0x400C7A: InsertObject (in /a/fr-01/vol/home/stud/ashers03/c/ex4/test) ==4214== by 0x401137: main (in /a/fr-01/vol/home/stud/ashers03/c/ex4/test) i get more errors on other functions, however it's same error. i can't understand why it is uninitialized. This is the main function: int main(int argc, char* argv[]) { size_t tableSize = (size_t)atoi(*(argv+1)); TableP table = CreateTable(tableSize,IntFcn, IntPrint,IntCompare); int i; for (i=FIRST; i<=LAST; i++) { int *key = (int*)malloc(sizeof(int)); *key = i; ObjectP obj = CreateObject(key); InsertObject(table,obj); } PrintTable(table); FreeTable(table); return 0; } these definitions are in a header file: typedef struct Object* ObjectP; typedef struct Table* TableP; typedef const struct Table* ConstTableP; typedef enum {FALSE, TRUE} Boolean; this code is in another file: typedef struct Table { ObjectP* _table; int _firstTableSize; int _currentTableSize; int _increaseFactor; HashFcn _hfun; PrintFcn _pfun; ComparisonFcn _fcomp; } Table; typedef struct Object { ObjectP _next; void* _key; int _numInChain; } Object; this function inserts a key to a hashtable. If 3 keys are already chained in the cell then size of the table is doubled and I'm doing some other things in doubleTable()... Boolean InsertObject(TableP table, ObjectP object) { int index=table->_increas
Tags (comma-separated)
Save Edits
Cancel