Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package uthash for openSUSE:Factory checked in at 2021-04-06 17:30:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/uthash (Old) and /work/SRC/openSUSE:Factory/.uthash.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "uthash" Tue Apr 6 17:30:18 2021 rev:6 rq:882810 version:2.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/uthash/uthash.changes 2021-01-06 19:57:13.933179551 +0100 +++ /work/SRC/openSUSE:Factory/.uthash.new.2401/uthash.changes 2021-04-06 17:31:43.939256145 +0200 @@ -1,0 +2,10 @@ +Fri Apr 02 11:20:21 UTC 2021 - Wang Jun <[email protected]> + +- udpate to 2.3.0: + * remove HASH_FCN; the HASH_FUNCTION and HASH_KEYCMP macros + now behave similarly + * remove uthash_memcmp (deprecated in v2.1.0) in favor of + HASH_KEYCMP + * silence -Wswitch-default warnings (thanks, Olaf Bergmann!) + +------------------------------------------------------------------- Old: ---- uthash-2.2.0.tar.gz New: ---- uthash-2.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ uthash.spec ++++++ --- /var/tmp/diff_new_pack.eSXZKf/_old 2021-04-06 17:31:44.607256901 +0200 +++ /var/tmp/diff_new_pack.eSXZKf/_new 2021-04-06 17:31:44.611256905 +0200 @@ -18,7 +18,7 @@ Name: uthash -Version: 2.2.0 +Version: 2.3.0 Release: 0 Summary: Inline hash table for C structures License: BSD-3-Clause ++++++ uthash-2.2.0.tar.gz -> uthash-2.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/.travis.yml new/uthash-2.3.0/.travis.yml --- old/uthash-2.2.0/.travis.yml 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/.travis.yml 2021-02-25 16:43:59.000000000 +0100 @@ -7,7 +7,7 @@ compiler: clang - os: osx script: -- make -C tests EXTRA_CFLAGS="-W -Wall -Wextra" +- make -C tests EXTRA_CFLAGS="-W -Wall -Wextra -Wswitch-default" - make -C tests clean ; make -C tests pedantic - make -C tests clean ; make -C tests pedantic EXTRA_CFLAGS=-DNO_DECLTYPE - make -C tests clean ; make -C tests cplusplus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/LICENSE new/uthash-2.3.0/LICENSE --- old/uthash-2.2.0/LICENSE 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/LICENSE 2021-02-25 16:43:59.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright (c) 2005-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2005-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/README.md new/uthash-2.3.0/README.md --- old/uthash-2.2.0/README.md 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/README.md 2021-02-25 16:43:59.000000000 +0100 @@ -1,8 +1,8 @@ -[](https://travis-ci.org/troydhanson/uthash) +[](https://travis-ci.org/troydhanson/uthash) Documentation for uthash is available at: -http://troydhanson.github.com/uthash/ +https://troydhanson.github.com/uthash/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/ChangeLog.txt new/uthash-2.3.0/doc/ChangeLog.txt --- old/uthash-2.2.0/doc/ChangeLog.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/ChangeLog.txt 2021-02-25 16:43:59.000000000 +0100 @@ -5,6 +5,12 @@ NOTE: This ChangeLog may be incomplete and/or incorrect. See the git commit log. +Version 2.3.0 (2021-02-25) +-------------------------- +* remove HASH_FCN; the HASH_FUNCTION and HASH_KEYCMP macros now behave similarly +* remove uthash_memcmp (deprecated in v2.1.0) in favor of HASH_KEYCMP +* silence -Wswitch-default warnings (thanks, Olaf Bergmann!) + Version 2.2.0 (2020-12-17) -------------------------- * add HASH_NO_STDINT for platforms without C99 <stdint.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/index.html new/uthash-2.3.0/doc/index.html --- old/uthash-2.2.0/doc/index.html 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/index.html 2021-02-25 16:43:59.000000000 +0100 @@ -72,7 +72,7 @@ struct my_struct *users = NULL; void add_user(struct my_struct *s) { - HASH_ADD_INT( users, id, s ); + HASH_ADD_INT(users, id, s); } </pre> @@ -86,7 +86,7 @@ struct my_struct *find_user(int user_id) { struct my_struct *s; - HASH_FIND_INT( users, &user_id, s ); + HASH_FIND_INT(users, &user_id, s); return s; } @@ -100,7 +100,7 @@ <pre> void delete_user(struct my_struct *user) { - HASH_DEL( users, user); + HASH_DEL(users, user); } </pre> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/license.html new/uthash-2.3.0/doc/license.html --- old/uthash-2.2.0/doc/license.html 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/license.html 2021-02-25 16:43:59.000000000 +0100 @@ -21,7 +21,7 @@ <div id="mid"> <div id="main"> <pre> -Copyright (c) 2005-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2005-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/userguide.txt new/uthash-2.3.0/doc/userguide.txt --- old/uthash-2.2.0/doc/userguide.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/userguide.txt 2021-02-25 16:43:59.000000000 +0100 @@ -1,7 +1,7 @@ uthash User Guide ================= Troy D. Hanson, Arthur O'Dwyer -v2.2.0, December 2020 +v2.3.0, February 2021 To download uthash, follow this link back to the https://github.com/troydhanson/uthash[GitHub project page]. @@ -218,7 +218,7 @@ s = malloc(sizeof(struct my_struct)); s->id = user_id; strcpy(s->name, name); - HASH_ADD_INT( users, id, s ); /* id: name of key field */ + HASH_ADD_INT(users, id, s); /* id: name of key field */ } ---------------------------------------------------------------------- @@ -256,10 +256,10 @@ struct my_struct *s; HASH_FIND_INT(users, &user_id, s); /* id already in the hash? */ - if (s==NULL) { + if (s == NULL) { s = (struct my_struct *)malloc(sizeof *s); s->id = user_id; - HASH_ADD_INT( users, id, s ); /* id: name of key field */ + HASH_ADD_INT(users, id, s); /* id: name of key field */ } strcpy(s->name, name); } @@ -284,7 +284,7 @@ /* bad */ void add_user(struct my_struct *users, int user_id, char *name) { ... - HASH_ADD_INT( users, id, s ); + HASH_ADD_INT(users, id, s); } You really need to pass 'a pointer' to the hash pointer: @@ -292,7 +292,7 @@ /* good */ void add_user(struct my_struct **users, int user_id, char *name) { ... ... - HASH_ADD_INT( *users, id, s ); + HASH_ADD_INT(*users, id, s); } Note that we dereferenced the pointer in the `HASH_ADD` also. @@ -319,7 +319,7 @@ struct my_struct *find_user(int user_id) { struct my_struct *s; - HASH_FIND_INT( users, &user_id, s ); /* s: output pointer */ + HASH_FIND_INT(users, &user_id, s); /* s: output pointer */ return s; } ---------------------------------------------------------------------- @@ -376,8 +376,8 @@ struct my_struct *current_user, *tmp; HASH_ITER(hh, users, current_user, tmp) { - HASH_DEL(users,current_user); /* delete; users advances to next */ - free(current_user); /* optional- if you want to free */ + HASH_DEL(users, current_user); /* delete; users advances to next */ + free(current_user); /* optional- if you want to free */ } } ---------------------------------------------------------------------- @@ -387,7 +387,7 @@ If you only want to delete all the items, but not free them or do any per-element clean up, you can do this more efficiently in a single operation: - HASH_CLEAR(hh,users); + HASH_CLEAR(hh, users); Afterward, the list head (here, `users`) will be set to `NULL`. @@ -403,7 +403,7 @@ printf("there are %u users\n", num_users); ---------------------------------------------------------------------- -Incidentally, this works even the list (`users`, here) is `NULL`, in +Incidentally, this works even if the list head (here, `users`) is `NULL`, in which case the count is 0. Iterating and sorting @@ -417,7 +417,7 @@ void print_users() { struct my_struct *s; - for(s=users; s != NULL; s=s->hh.next) { + for (s = users; s != NULL; s = s->hh.next) { printf("user id %d: name %s\n", s->id, s->name); } } @@ -430,7 +430,7 @@ Deletion-safe iteration ^^^^^^^^^^^^^^^^^^^^^^^ In the example above, it would not be safe to delete and free `s` in the body -of the 'for' loop, (because `s` is derefenced each time the loop iterates). +of the 'for' loop, (because `s` is dereferenced each time the loop iterates). This is easy to rewrite correctly (by copying the `s->hh.next` pointer to a temporary variable 'before' freeing `s`), but it comes up often enough that a deletion-safe iteration macro, `HASH_ITER`, is included. It expands to a @@ -452,14 +452,14 @@ ******************************************************************************* If you're using uthash in a C++ program, you need an extra cast on the `for` -iterator, e.g., `s=(struct my_struct*)s->hh.next`. +iterator, e.g., `s = static_cast<my_struct*>(s->hh.next)`. Sorting ^^^^^^^ The items in the hash are visited in "insertion order" when you follow the `hh.next` pointer. You can sort the items into a new order using `HASH_SORT`. - HASH_SORT( users, name_sort ); + HASH_SORT(users, name_sort); The second argument is a pointer to a comparison function. It must accept two pointer arguments (the items to compare), and must return an `int` which is @@ -480,7 +480,7 @@ .Sorting the items in the hash ---------------------------------------------------------------------- int name_sort(struct my_struct *a, struct my_struct *b) { - return strcmp(a->name,b->name); + return strcmp(a->name, b->name); } int id_sort(struct my_struct *a, struct my_struct *b) { @@ -533,10 +533,10 @@ struct my_struct *s; HASH_FIND_INT(users, &user_id, s); /* id already in the hash? */ - if (s==NULL) { + if (s == NULL) { s = (struct my_struct *)malloc(sizeof *s); s->id = user_id; - HASH_ADD_INT( users, id, s ); /* id: name of key field */ + HASH_ADD_INT(users, id, s); /* id: name of key field */ } strcpy(s->name, name); } @@ -544,7 +544,7 @@ struct my_struct *find_user(int user_id) { struct my_struct *s; - HASH_FIND_INT( users, &user_id, s ); /* s: output pointer */ + HASH_FIND_INT(users, &user_id, s); /* s: output pointer */ return s; } @@ -565,13 +565,13 @@ void print_users() { struct my_struct *s; - for(s=users; s != NULL; s=(struct my_struct*)(s->hh.next)) { + for (s = users; s != NULL; s = (struct my_struct*)(s->hh.next)) { printf("user id %d: name %s\n", s->id, s->name); } } int name_sort(struct my_struct *a, struct my_struct *b) { - return strcmp(a->name,b->name); + return strcmp(a->name, b->name); } int id_sort(struct my_struct *a, struct my_struct *b) { @@ -588,7 +588,7 @@ int main(int argc, char *argv[]) { char in[10]; - int id=1, running=1; + int id = 1, running = 1; struct my_struct *s; unsigned num_users; @@ -639,11 +639,11 @@ print_users(); break; case 9: - num_users=HASH_COUNT(users); + num_users = HASH_COUNT(users); printf("there are %u users\n", num_users); break; case 10: - running=0; + running = 0; break; } } @@ -720,10 +720,10 @@ s = (struct my_struct *)malloc(sizeof *s); strcpy(s->name, names[i]); s->id = i; - HASH_ADD_STR( users, name, s ); + HASH_ADD_STR(users, name, s); } - HASH_FIND_STR( users, "betty", s); + HASH_FIND_STR(users, "betty", s); if (s) printf("betty's id is %d\n", s->id); /* free the hash table contents */ @@ -766,10 +766,10 @@ s = (struct my_struct *)malloc(sizeof *s); s->name = names[i]; s->id = i; - HASH_ADD_KEYPTR( hh, users, s->name, strlen(s->name), s ); + HASH_ADD_KEYPTR(hh, users, s->name, strlen(s->name), s); } - HASH_FIND_STR( users, "betty", s); + HASH_FIND_STR(users, "betty", s); if (s) printf("betty's id is %d\n", s->id); /* free the hash table contents */ @@ -812,12 +812,12 @@ if (!e) return -1; e->key = (void*)someaddr; e->i = 1; - HASH_ADD_PTR(hash,key,e); + HASH_ADD_PTR(hash, key, e); HASH_FIND_PTR(hash, &someaddr, d); if (d) printf("found\n"); /* release memory */ - HASH_DEL(hash,e); + HASH_DEL(hash, e); free(e); return 0; } @@ -924,7 +924,7 @@ int beijing[] = {0x5317, 0x4eac}; /* UTF-32LE for ?????? */ /* allocate and initialize our structure */ - msg = (msg_t *)malloc( sizeof(msg_t) + sizeof(beijing) ); + msg = (msg_t *)malloc(sizeof(msg_t) + sizeof(beijing)); memset(msg, 0, sizeof(msg_t)+sizeof(beijing)); /* zero fill */ msg->len = sizeof(beijing); msg->encoding = UTF32; @@ -936,16 +936,16 @@ - offsetof(msg_t, encoding); /* offset of first key field */ /* add our structure to the hash table */ - HASH_ADD( hh, msgs, encoding, keylen, msg); + HASH_ADD(hh, msgs, encoding, keylen, msg); /* look it up to prove that it worked :-) */ - msg=NULL; + msg = NULL; lookup_key = (lookup_key_t *)malloc(sizeof(*lookup_key) + sizeof(beijing)); memset(lookup_key, 0, sizeof(*lookup_key) + sizeof(beijing)); lookup_key->encoding = UTF32; memcpy(lookup_key->text, beijing, sizeof(beijing)); - HASH_FIND( hh, msgs, &lookup_key->encoding, keylen, msg ); + HASH_FIND(hh, msgs, &lookup_key->encoding, keylen, msg); if (msg) printf("found \n"); free(lookup_key); @@ -1028,7 +1028,7 @@ UT_hash_handle hh; } item_t; -item_t *items=NULL; +item_t *items = NULL; int main(int argc, char *argvp[]) { item_t *item1, *item2, *tmp1, *tmp2; @@ -1128,7 +1128,7 @@ HASH_ADD(hh2, users_by_name, username, strlen(s->username), s); /* find user by ID in the "users_by_id" hash table */ - i=1; + i = 1; HASH_FIND(hh1, users_by_id, &i, sizeof(int), s); if (s) printf("found id %d: %s\n", i, s->username); @@ -1155,7 +1155,7 @@ with an additional comparison-function argument: int name_sort(struct my_struct *a, struct my_struct *b) { - return strcmp(a->name,b->name); + return strcmp(a->name, b->name); } HASH_ADD_KEYPTR_INORDER(hh, items, &item->name, strlen(item->name), item, name_sort); @@ -1183,7 +1183,7 @@ } int sort_by_name(struct my_struct *a, struct my_struct *b) { - return strcmp(a->username,b->username); + return strcmp(a->username, b->username); } HASH_SRT(hh1, users_by_id, sort_by_id); @@ -1240,7 +1240,8 @@ handles. (As described <<multihash,here>>, a structure can exist in many hash tables at the same time; it must have a separate hash handle for each one). - user_t *users=NULL, *admins=NULL; /* two hash tables */ + user_t *users = NULL; /* hash table of users */ + user_t *admins = NULL; /* hash table of admins */ typedef struct { int id; @@ -1252,25 +1253,26 @@ users who have id's less than 1024. #define is_admin(x) (((user_t*)x)->id < 1024) - HASH_SELECT(ah,admins,hh,users,is_admin); + HASH_SELECT(ah, admins, hh, users, is_admin); The first two parameters are the 'destination' hash handle and hash table, the second two parameters are the 'source' hash handle and hash table, and the last -parameter is the 'select condition'. Here we used a macro `is_admin()` but we +parameter is the 'select condition'. Here we used a macro `is_admin(x)` but we could just as well have used a function. - int is_admin(void *userv) { - user_t *user = (user_t*)userv; + int is_admin(const void *userv) { + user_t *user = (const user_t*)userv; return (user->id < 1024) ? 1 : 0; } If the select condition always evaluates to true, this operation is -essentially a 'merge' of the source hash into the destination hash. Of course, -the source hash remains unchanged under any use of `HASH_SELECT`. It only adds -items to the destination hash selectively. +essentially a 'merge' of the source hash into the destination hash. + +`HASH_SELECT` adds items to the destination without removing them from +the source; the source hash table remains unchanged. The destination hash table +must not be the same as the source hash table. -The two hash handles must differ. An example of using `HASH_SELECT` is included -in `tests/test36.c`. +An example of using `HASH_SELECT` is included in `tests/test36.c`. [[hash_keycompare]] Specifying an alternate key comparison function @@ -1290,7 +1292,7 @@ ---------------------------------------------------------------------------- #undef HASH_KEYCMP -#define HASH_KEYCMP(a,b,len) bcmp(a,b,len) +#define HASH_KEYCMP(a,b,len) bcmp(a, b, len) ---------------------------------------------------------------------------- Another reason to substitute your own key comparison function is if your "key" is not @@ -1631,7 +1633,7 @@ /* re-define, specifying alternate functions */ #define uthash_malloc(sz) my_malloc(sz) -#define uthash_free(ptr,sz) my_free(ptr) +#define uthash_free(ptr, sz) my_free(ptr) ... ---------------------------------------------------------------------------- @@ -1647,7 +1649,7 @@ ---------------------------------------------------------------------------- #undef uthash_bzero -#define uthash_bzero(a,len) my_bzero(a,len) +#define uthash_bzero(a, len) my_bzero(a, len) #undef uthash_strlen #define uthash_strlen(s) my_strlen(s) @@ -1754,7 +1756,7 @@ For example using pthreads you can create an rwlock like this: pthread_rwlock_t lock; - if (pthread_rwlock_init(&lock,NULL) != 0) fatal("can't create rwlock"); + if (pthread_rwlock_init(&lock, NULL) != 0) fatal("can't create rwlock"); Then, readers must acquire the read lock before doing any `HASH_FIND` calls or before iterating over the hash elements: @@ -1795,10 +1797,10 @@ |=============================================================================== |macro | arguments |HASH_ADD_INT | (head, keyfield_name, item_ptr) -|HASH_REPLACE_INT | (head, keyfiled_name, item_ptr,replaced_item_ptr) +|HASH_REPLACE_INT | (head, keyfield_name, item_ptr, replaced_item_ptr) |HASH_FIND_INT | (head, key_ptr, item_ptr) |HASH_ADD_STR | (head, keyfield_name, item_ptr) -|HASH_REPLACE_STR | (head,keyfield_name, item_ptr, replaced_item_ptr) +|HASH_REPLACE_STR | (head, keyfield_name, item_ptr, replaced_item_ptr) |HASH_FIND_STR | (head, key_ptr, item_ptr) |HASH_ADD_PTR | (head, keyfield_name, item_ptr) |HASH_REPLACE_PTR | (head, keyfield_name, item_ptr, replaced_item_ptr) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/utarray.txt new/uthash-2.3.0/doc/utarray.txt --- old/uthash-2.2.0/doc/utarray.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/utarray.txt 2021-02-25 16:43:59.000000000 +0100 @@ -1,7 +1,7 @@ utarray: dynamic array macros for C =================================== Troy D. Hanson <[email protected]> -v2.2.0, December 2020 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthash[GitHub project page]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/utlist.txt new/uthash-2.3.0/doc/utlist.txt --- old/uthash-2.2.0/doc/utlist.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/utlist.txt 2021-02-25 16:43:59.000000000 +0100 @@ -1,7 +1,7 @@ utlist: linked list macros for C structures =========================================== Troy D. Hanson <[email protected]> -v2.2.0, December 2020 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthash[GitHub project page]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/utringbuffer.txt new/uthash-2.3.0/doc/utringbuffer.txt --- old/uthash-2.2.0/doc/utringbuffer.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/utringbuffer.txt 2021-02-25 16:43:59.000000000 +0100 @@ -1,7 +1,7 @@ utringbuffer: dynamic ring-buffer macros for C ============================================== Arthur O'Dwyer <[email protected]> -v2.2.0, December 2020 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthash[GitHub project page]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/utstack.txt new/uthash-2.3.0/doc/utstack.txt --- old/uthash-2.2.0/doc/utstack.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/utstack.txt 2021-02-25 16:43:59.000000000 +0100 @@ -1,7 +1,7 @@ utstack: intrusive stack macros for C ===================================== Arthur O'Dwyer <[email protected]> -v2.2.0, December 2020 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthash[GitHub project page]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/doc/utstring.txt new/uthash-2.3.0/doc/utstring.txt --- old/uthash-2.2.0/doc/utstring.txt 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/doc/utstring.txt 2021-02-25 16:43:59.000000000 +0100 @@ -1,7 +1,7 @@ utstring: dynamic string macros for C ===================================== Troy D. Hanson <[email protected]> -v2.2.0, December 2020 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthash[GitHub project page]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/package.json new/uthash-2.3.0/package.json --- old/uthash-2.2.0/package.json 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/package.json 2021-02-25 16:43:59.000000000 +0100 @@ -24,5 +24,5 @@ "src/utstring.h" ], - "version": "2.2.0" + "version": "2.3.0" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/src/utarray.h new/uthash-2.3.0/src/utarray.h --- old/uthash-2.2.0/src/utarray.h 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/src/utarray.h 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2008-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ #ifndef UTARRAY_H #define UTARRAY_H -#define UTARRAY_VERSION 2.2.0 +#define UTARRAY_VERSION 2.3.0 #include <stddef.h> /* size_t */ #include <string.h> /* memset, etc */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/src/uthash.h new/uthash-2.3.0/src/uthash.h --- old/uthash-2.2.0/src/uthash.h 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/src/uthash.h 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2003-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ #ifndef UTHASH_H #define UTHASH_H -#define UTHASH_VERSION 2.2.0 +#define UTHASH_VERSION 2.3.0 #include <string.h> /* memcmp, memset, strlen */ #include <stddef.h> /* ptrdiff_t */ @@ -85,15 +85,12 @@ #define uthash_strlen(s) strlen(s) #endif -#ifdef uthash_memcmp -/* This warning will not catch programs that define uthash_memcmp AFTER including uthash.h. */ -#warning "uthash_memcmp is deprecated; please use HASH_KEYCMP instead" -#else -#define uthash_memcmp(a,b,n) memcmp(a,b,n) +#ifndef HASH_FUNCTION +#define HASH_FUNCTION(keyptr,keylen,hashv) HASH_JEN(keyptr, keylen, hashv) #endif #ifndef HASH_KEYCMP -#define HASH_KEYCMP(a,b,n) uthash_memcmp(a,b,n) +#define HASH_KEYCMP(a,b,n) memcmp(a,b,n) #endif #ifndef uthash_noexpand_fyi @@ -151,7 +148,7 @@ #define HASH_VALUE(keyptr,keylen,hashv) \ do { \ - HASH_FCN(keyptr, keylen, hashv); \ + HASH_FUNCTION(keyptr, keylen, hashv); \ } while (0) #define HASH_FIND_BYHASHVALUE(hh,head,keyptr,keylen,hashval,out) \ @@ -583,13 +580,6 @@ #define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) #endif -/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ -#ifdef HASH_FUNCTION -#define HASH_FCN HASH_FUNCTION -#else -#define HASH_FCN HASH_JEN -#endif - /* The Bernstein hash function, used in Perl prior to v5.6. Note (x<<5+x)=x*33. */ #define HASH_BER(key,keylen,hashv) \ do { \ @@ -688,7 +678,8 @@ case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); /* FALLTHROUGH */ \ case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); /* FALLTHROUGH */ \ case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); /* FALLTHROUGH */ \ - case 1: _hj_i += _hj_key[0]; \ + case 1: _hj_i += _hj_key[0]; /* FALLTHROUGH */ \ + default: ; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ } while (0) @@ -736,6 +727,8 @@ case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ + break; \ + default: ; \ } \ \ /* Force "avalanching" of final 127 bits */ \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/src/utlist.h new/uthash-2.3.0/src/utlist.h --- old/uthash-2.2.0/src/utlist.h 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/src/utlist.h 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2007-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2007-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ #ifndef UTLIST_H #define UTLIST_H -#define UTLIST_VERSION 2.2.0 +#define UTLIST_VERSION 2.3.0 #include <assert.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/src/utringbuffer.h new/uthash-2.3.0/src/utringbuffer.h --- old/uthash-2.2.0/src/utringbuffer.h 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/src/utringbuffer.h 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2015-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ #ifndef UTRINGBUFFER_H #define UTRINGBUFFER_H -#define UTRINGBUFFER_VERSION 2.2.0 +#define UTRINGBUFFER_VERSION 2.3.0 #include <stdlib.h> #include <string.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/src/utstack.h new/uthash-2.3.0/src/utstack.h --- old/uthash-2.2.0/src/utstack.h 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/src/utstack.h 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2018-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ #ifndef UTSTACK_H #define UTSTACK_H -#define UTSTACK_VERSION 2.2.0 +#define UTSTACK_VERSION 2.3.0 /* * This file contains macros to manipulate a singly-linked list as a stack. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/src/utstring.h new/uthash-2.3.0/src/utstring.h --- old/uthash-2.2.0/src/utstring.h 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/src/utstring.h 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2008-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ #ifndef UTSTRING_H #define UTSTRING_H -#define UTSTRING_VERSION 2.2.0 +#define UTSTRING_VERSION 2.3.0 #include <stdlib.h> #include <string.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/tests/example.c new/uthash-2.3.0/tests/example.c --- old/uthash-2.2.0/tests/example.c 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/tests/example.c 2021-02-25 16:43:59.000000000 +0100 @@ -16,10 +16,10 @@ struct my_struct *s; HASH_FIND_INT(users, &user_id, s); /* id already in the hash? */ - if (s==NULL) { + if (s == NULL) { s = (struct my_struct*)malloc(sizeof(struct my_struct)); s->id = user_id; - HASH_ADD_INT( users, id, s ); /* id: name of key field */ + HASH_ADD_INT(users, id, s); /* id: name of key field */ } strcpy(s->name, name); } @@ -28,13 +28,13 @@ { struct my_struct *s; - HASH_FIND_INT( users, &user_id, s ); /* s: output pointer */ + HASH_FIND_INT(users, &user_id, s); /* s: output pointer */ return s; } void delete_user(struct my_struct *user) { - HASH_DEL( users, user); /* user: pointer to deletee */ + HASH_DEL(users, user); /* user: pointer to deletee */ free(user); } @@ -43,8 +43,8 @@ struct my_struct *current_user, *tmp; HASH_ITER(hh, users, current_user, tmp) { - HASH_DEL(users,current_user); /* delete it (users advances to next) */ - free(current_user); /* free it */ + HASH_DEL(users, current_user); /* delete it (users advances to next) */ + free(current_user); /* free it */ } } @@ -52,14 +52,14 @@ { struct my_struct *s; - for(s=users; s != NULL; s=(struct my_struct*)(s->hh.next)) { + for (s = users; s != NULL; s = (struct my_struct*)(s->hh.next)) { printf("user id %d: name %s\n", s->id, s->name); } } int name_sort(struct my_struct *a, struct my_struct *b) { - return strcmp(a->name,b->name); + return strcmp(a->name, b->name); } int id_sort(struct my_struct *a, struct my_struct *b) @@ -80,7 +80,7 @@ int main() { char in[10]; - int id=1, running=1; + int id = 1, running = 1; struct my_struct *s; unsigned num_users; @@ -135,11 +135,11 @@ print_users(); break; case 9: - num_users=HASH_COUNT(users); + num_users = HASH_COUNT(users); printf("there are %u users\n", num_users); break; case 10: - running=0; + running = 0; break; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/tests/hashscan.c new/uthash-2.3.0/tests/hashscan.c --- old/uthash-2.2.0/tests/hashscan.c 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/tests/hashscan.c 2021-02-25 16:43:59.000000000 +0100 @@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2020, Troy D. Hanson http://troydhanson.github.com/uthash/ +Copyright (c) 2005-2021, Troy D. Hanson http://troydhanson.github.com/uthash/ All rights reserved. Redistribution and use in source and binary forms, with or without diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/tests/test76.c new/uthash-2.3.0/tests/test76.c --- old/uthash-2.2.0/tests/test76.c 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/tests/test76.c 2021-02-25 16:43:59.000000000 +0100 @@ -8,8 +8,8 @@ char V_NeedleStr[] = "needle\0s"; long *V_KMP_Table; long V_FindPos; - size_t V_StartPos; - size_t V_FindCnt; + size_t V_StartPos = 0; + size_t V_FindCnt = 0; utstring_new(s); @@ -24,9 +24,6 @@ if (V_KMP_Table != NULL) { _utstring_BuildTable(utstring_body(t), utstring_len(t), V_KMP_Table); - V_FindCnt = 0; - V_FindPos = 0; - V_StartPos = 0; do { V_FindPos = _utstring_find(utstring_body(s) + V_StartPos, utstring_len(s) - V_StartPos, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/tests/test77.c new/uthash-2.3.0/tests/test77.c --- old/uthash-2.2.0/tests/test77.c 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/tests/test77.c 2021-02-25 16:43:59.000000000 +0100 @@ -9,7 +9,7 @@ long *V_KMP_Table; long V_FindPos; size_t V_StartPos; - size_t V_FindCnt; + size_t V_FindCnt = 0; utstring_new(s); @@ -24,8 +24,6 @@ if (V_KMP_Table != NULL) { _utstring_BuildTableR(utstring_body(t), utstring_len(t), V_KMP_Table); - V_FindCnt = 0; - V_FindPos = 0; V_StartPos = utstring_len(s) - 1; do { V_FindPos = _utstring_findR(utstring_body(s), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uthash-2.2.0/tests/test93.c new/uthash-2.3.0/tests/test93.c --- old/uthash-2.2.0/tests/test93.c 2020-12-17 17:09:01.000000000 +0100 +++ new/uthash-2.3.0/tests/test93.c 2021-02-25 16:43:59.000000000 +0100 @@ -39,43 +39,39 @@ longjmp(j_buf, 1); } -static example_user_t * init_user(int need_malloc_cnt) { - users = 0; +static void init_users(int need_malloc_cnt) { + users = NULL; example_user_t * user = (example_user_t*)malloc(sizeof(example_user_t)); user->id = user_id; is_fatal = 0; malloc_cnt = need_malloc_cnt; - /* printf("adding to hash...\n"); */ if (!setjmp(j_buf)) { HASH_ADD_INT(users, id, user); + } else { + free(user); } - return user; } int main() { + example_user_t *user; -#define init(a) do { \ -} while(0) - - example_user_t * user; - - user = init_user(3); /* bloom filter must fail */ + init_users(3); /* bloom filter must fail */ if (!is_fatal) { printf("fatal not called after bloom failure\n"); } - user = init_user(2); /* bucket creation must fail */ + init_users(2); /* bucket creation must fail */ if (!is_fatal) { printf("fatal not called after bucket creation failure\n"); } - user = init_user(1); /* table creation must fail */ + init_users(1); /* table creation must fail */ if (!is_fatal) { printf("fatal not called after table creation failure\n"); } - user = init_user(4); /* hash must create OK */ + init_users(4); /* hash must create OK */ if (is_fatal) { printf("fatal error when creating hash normally\n"); /* bad idea to continue running */ @@ -83,19 +79,20 @@ } /* let's add users until expansion fails */ - users = 0; + users = NULL; malloc_cnt = 4; while (1) { - user = (example_user_t*)malloc(sizeof(example_user_t)); - user->id = user_id; if (user_id++ == 1000) { printf("there is no way 1000 iterations didn't require realloc\n"); break; } + user = (example_user_t*)malloc(sizeof(example_user_t)); + user->id = user_id; if (!setjmp(j_buf)) { HASH_ADD_INT(users, id, user); + } else { + free(user); } - malloc_cnt = 0; if (malloc_failed) { if (!is_fatal) { @@ -108,12 +105,12 @@ /* we can't really do anything, the hash is not in consistent * state, so assume this is a success. */ break; - } + malloc_cnt = 0; } - printf("End\n"); + HASH_CLEAR(hh, users); + printf("End\n"); return 0; - }
