c_hashmap icon indicating copy to clipboard operation
c_hashmap copied to clipboard

is possible write and read from file ?

Open denisdemais opened this issue 9 years ago • 2 comments

denisdemais avatar Jun 09 '16 08:06 denisdemais

To write the whole hashmap to a file, you'd have to write your own serialization code. You could rewrite hashmap_iterate() to do that. The current version of hashmap_iterate() calls a function for every hashmap entry. The new version could add the item key as function parameter. To read the hashmap back, your own deserialization code would be needed. Does this answer your question?

a1880 avatar Jun 09 '16 14:06 a1880

yes, you do.

i will try save directly to disk. i will report you.

suggest #1 zlib zlib have a crc32 code do you can add additional support if defined, i.e., HAVE_ZLIB

suggest #2 change to avoid conflit with zlib from: unsigned long crc32(const unsigned char *s, unsigned int len) to: static unsigned long crc32(const unsigned char *s, unsigned int len)

suggest #3 static modifier can vary between compilers

suggest #4 uses of errorno and/or hashmap_strerror() i.e., at map_t hashmap_new() 'just' return NULL but can determine a cause of error

suggest #5 check if hashmap is valid before free() at void hashmap_free()

denisdemais avatar Jun 10 '16 10:06 denisdemais