hashdict.c icon indicating copy to clipboard operation
hashdict.c copied to clipboard

Any HASHDICT_VALUE_TYPE

Open senyai opened this issue 4 years ago • 2 comments

Hi!

The documentations says the value type is defined as int in the header file, you can redefine it to the required type, which could be char or void* or anything you need., but https://github.com/exebook/hashdict.c/blob/d821398128ecbc964c381849603ec5bd4a0d7bbf/hashdict.c#L26 assigns -1 to that value and you can't assing -1 to a void *, don't you?

senyai avatar Jun 30 '21 18:06 senyai

@senyai I think -1 will work for void* because I do not think that could possibly be a valid pointer in either 32 or 64 bit addressing systems, but you're right something have to be done about this magic number, maybe we could introduce a constant.

exebook avatar Nov 30 '21 15:11 exebook

I support this feature request, as it will not work for types like structs (kinda weird as you should use a pointer) but for UNIONS there is some problems, as you need to access a "field" (or interpretation of data). Maybe something in the lines of

#define HASHDICT_DEFAULT_ASSIGNMENT_OPERATION node->value.f64 = 0.

Thank you for the great work!

forcegk avatar Dec 13 '23 07:12 forcegk