Questions tagged [uthash]

15 questions
3
votes
2 answers

Invalid read in hash table

I'm using uthash.h in order to store my application's configuration. As the config comes from a file that is read at runtime, the keys and values within the hash are both dynamically allocated char *'s: typedef struct config_entry { char *name; …
DeX3
  • 5,200
  • 6
  • 44
  • 68
2
votes
0 answers

uthash delete and memory leaks, valgrind

I use uthash hash table implementation with structs. I have two hash tables, one of them (dataTable in code) collect some info in loop and when it finishes, save some of the data in the other hashtable (that is stuffTable). My program works(at…
user3717434
  • 215
  • 4
  • 19
1
vote
1 answer

The method HASH_ADD does not add the new elements to the hash table. Using uthash.h

Based on the documentation found here, I wrote the following code in C: adj_hash_table.h typedef struct { int id_0; int id_1; }id_t_; typedef struct { id_t_ id; double value; UT_hash_handle hh; }cell_t; void add_(int id_0, int…
mm_
  • 1,566
  • 2
  • 18
  • 37
1
vote
1 answer

uthash adding a new entry to a hashmap

I want to create a hashmap with uthash. I want the key and the value to be a struct, containing a String and a size_t like this: typedef struct hash_ptr { char* string; size_t len; }hash_ptr; The hash table itself looks like this: typedef…
rn42v
  • 97
  • 6
1
vote
2 answers

Are uthash and utarray backward compatible?

I'm specifically concerned about utarray version 2.0.2 vs. 1.9.6. (The most recent copyrights being 2017 and 2012, respectively). I need to add uthash.h to an existing project that makes use of utarray.h, and would rather both these headers come…
zzxyz
  • 2,953
  • 1
  • 16
  • 31
1
vote
1 answer

Using uthash HASH_ADD_KEYPTR (segmentation fault)

So I am trying to use uthash with the following struct(s) typedef struct hash_item hash_item; typedef struct value_List value_List; struct hash_item{ void * key; value_List * values; UT_hash_handle hh; /* makes this…
Brandon Amir
  • 380
  • 1
  • 6
  • 16
1
vote
1 answer

UTHash in function call does iteration once but not second time

I am having some issues with usage of a uthash on a local variable. My code looks something like this, query_dict is a local variable uthash: main functions: query* query_dict = NULL; split_query_into_terms(querystr, &query_dict); …
Eivind
  • 51
  • 5
1
vote
1 answer

UTHash multilevel hash table crashing on HASH_FIND_STR

I have two structures like so: struct item2_map{ char stringkey[MAX_SIZE]; UT_hash_handle hh; } struct item1_map{ int key1; struct item2_map *item2_map; UT_hash_handle hh; } In my code I do something like this struct item1_map *retrieved; struct…
Derek
  • 11,715
  • 32
  • 127
  • 228
0
votes
1 answer

uthash C HASH_FIND

I've got a homework from university and are supposed to use the library uthash to implement a hashtable including a set-, get- and delete-function. Hashtable is our struct containing a key, its length, a value, its length too and a UT_hash_handle…
slayze
  • 21
  • 3
0
votes
0 answers

Add integer array as key in uthash in c

I came across uthash, a opensource library for hash table implementation in c programming language. I found it good and decided to use it in my project. Right now I am stuck with one issue . I stared with small implementation where I created a hash…
sachu
  • 11
  • 2
0
votes
1 answer

UTHash Segmentation fault when modifying example using struct as key

I'm trying to use UTHash by modifying the Standard Key Types, Struct Keys example for my purposes seen in the following link: https://troydhanson.github.io/uthash/userguide.html#_structure_keys Here is the my modified code (stripped down to show…
HXSP1947
  • 1,311
  • 1
  • 16
  • 39
0
votes
1 answer

(int, const char *) as a compound key with the uthash library

I would like to use the uthash library for a hash table with a pair of int and const char * as a compound key: typedef struct entry_s { // This field is needed by the uthash library UT_hash_handle hh; // Values /* ... */ //…
Alexander Pozdneev
  • 1,289
  • 1
  • 13
  • 31
0
votes
1 answer

uthash: 2 level hash table, adding new elements in the nested table

I have a 2 level hash table as explained here(uthash), with two different struct as declared below. Hash struct b holds total count of s values and their frequency by parameter d in hash struct a(To understand better look at the design below).…
user3717434
  • 215
  • 4
  • 19
0
votes
2 answers

"implicit declaration of function" in utarray.h (part of uthash)

I'm using utarray (part of the uthash library) for a project. Whenever I include it, I get the following error: utarray.h:221:3: error: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration] Admittedly, I use some pretty…
-3
votes
1 answer

Issue with assignment from incompatible pointer type

Hey so im trying to attempt to read in a file, store it in a hash and then copy it. However i get the incompatible pointer type struct hash_struct { int id; char name[BUFFER_SIZE]; /* key (string WITHIN the…
Icey
  • 1
  • 1