Projects
Mega:23.09
uthash
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
_service:tar_scm:uthash.spec
Changed
@@ -1,13 +1,12 @@ -%global debug_package %{nil} Name: uthash -Version: 2.1.0 +Version: 2.3.0 Release: 1 Summary: Hash table for C structures License: BSD URL: https://github.com/troydhanson/uthash Source0: https://github.com/troydhanson/uthash/archive/v%{version}.tar.gz -BuildRequires: asciidoc +BuildRequires: asciidoc gcc make perl-interpreter perl(strict) perl(warnings) %description This package provides hash table for C structures. It isn't a library but a single header file, so there is no library code to link against. It has been tested on @@ -17,10 +16,26 @@ %package devel Summary: Header and library files for uthash - +Provides: %{name} = %{version}-%{release} +Obsoletes: %{name} < %{version}-%{release} %description devel Header and library files for uthash +%package tools +Summary: Command-line utilities for %{name} +Requires: %{name}-devel = %{version}-%{release} + +%description tools +This package provides the hashscan and keystats utility programs +for %{name}. + +The hashscan program examines a running process and reports on the +uthash tables that it finds in that program’s memory. It can also +save the keys from each table in a format that can be fed into keystats. + +The keystats program is able to analyze which hash function has the best +characteristics on the set of keys reported by the hashscan program. + %package help Summary: Documentation for uthash BuildArch: noarch @@ -32,35 +47,35 @@ %autosetup -p1 %build -cd doc/ -%make_build V=1 -cd .. +%set_build_flags +%make_build -C doc +%make_build -C tests +%make_build -C tests/threads %install -install -d %{buildroot}%{_prefix}/share/doc/uthash -install -d %{buildroot}%{_prefix}/share/licenses/uthash/ -cp LICENSE %{buildroot}%{_prefix}/share/licenses/uthash/ -cp README.md %{buildroot}%{_prefix}/share/doc/uthash/ - -install -d %{buildroot}%{_includedir} -cd src/ -cp * %{buildroot}%{_includedir} -cd .. - -install -d %{buildroot}%{_libdir} - -%files -%doc %{_prefix}/share/licenses/uthash/LICENSE -%doc %{_prefix}/share/doc/uthash/README.md +mkdir -p %{buildroot}{%{_bindir},%{_includedir},%{_pkgdocdir}/html} +install -pm 0755 tests/{hashscan,keystats} %{buildroot}%{_bindir} +install -pm 0644 src/*.h %{buildroot}%{_includedir} +install -pm 0644 doc/*.txt tests/example.c %{buildroot}%{_pkgdocdir} +install -pm 0644 doc/*.html doc/*.css doc/*.png %{buildroot}%{_pkgdocdir}/html +rm -f %{buildroot}%{_pkgdocdir}/html/google*.html %files devel -%{_includedir}/* +%license LICENSE +%doc %dir %{_pkgdocdir} +%doc %{_pkgdocdir}/ChangeLog.txt +%{_includedir}/*.h + +%files tools +%{_bindir}/* %files help -%doc %{_prefix}/share/doc/uthash/* -%exclude %{_prefix}/share/doc/uthash/README.md +%doc %{_pkgdocdir} %changelog +* Wed Aug 23 2023 liyanan <thistleslyn@163.com> - 2.3.0-1 +- Update to 2.3.0 + * Tue Jun 02 2020 huanghaitao <huanghaitao8@huawei.com> - 2.1.0-1 - Change source to latest update
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="url">git@gitee.com:src-openeuler/uthash.git</param> <param name="scm">git</param> - <param name="revision">openEuler-23.09</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:v2.1.0.tar.gz/tests/mexpand
Deleted
@@ -1,21 +0,0 @@ -#!/bin/bash - -# utility to macro-expand a test program -CC=gcc -#CPPFLAGS=-DHASH_DEBUG=1 -#CC=g++ -CPPFLAGS="-m64 -O3" -CFLAGS="-O3 -m64 -pedantic -Wall" - -${CC} ${CPPFLAGS} -E -I../src $1 | egrep -v '^#' > /tmp/$1 -indent /tmp/$1 -${CC} ${CFLAGS} -o /tmp/$1.$$ /tmp/$1 -rm -f /tmp/$1.$$ - -read -p "open /tmp/$1 ? n " response -if "$response" = "y" -then - vi /tmp/$1 -fi - -
View file
_service:tar_scm:v2.3.0.tar.gz/.travis.yml
Added
@@ -0,0 +1,14 @@ +language: cpp +matrix: + include: + - os: linux + compiler: gcc + - os: linux + compiler: clang + - os: osx +script: +- 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 +- make -C tests clean ; make -C tests cplusplus EXTRA_CFLAGS=-DNO_DECLTYPE
View file
_service:tar_scm:v2.1.0.tar.gz/LICENSE -> _service:tar_scm:v2.3.0.tar.gz/LICENSE
Changed
@@ -1,4 +1,4 @@ -Copyright (c) 2005-2018, 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
View file
_service:tar_scm:v2.1.0.tar.gz/README.md -> _service:tar_scm:v2.3.0.tar.gz/README.md
Changed
@@ -1,6 +1,8 @@ +!Build status(https://api.travis-ci.org/troydhanson/uthash.svg?branch=master)(https://travis-ci.org/troydhanson/uthash) + Documentation for uthash is available at: -http://troydhanson.github.com/uthash/ +https://troydhanson.github.com/uthash/
View file
_service:tar_scm:v2.1.0.tar.gz/doc/ChangeLog.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/ChangeLog.txt
Changed
@@ -5,6 +5,21 @@ 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> +* silence many -Wcast-qual warnings (thanks, Olaf Bergmann!) +* skip hash computation when finding in an empty hash (thanks, Huansong Fu!) +* rename oom to utarray_oom, in utarray.h (thanks, Hong Xu!) +* rename oom to utstring_oom, in utstring.h (thanks, Hong Xu!) +* remove MurmurHash/HASH_MUR + Version 2.1.0 (2018-12-20) -------------------------- * silence some Clang static analysis warnings
View file
_service:tar_scm:v2.1.0.tar.gz/doc/index.html -> _service:tar_scm:v2.3.0.tar.gz/doc/index.html
Changed
@@ -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>
View file
_service:tar_scm:v2.1.0.tar.gz/doc/license.html -> _service:tar_scm:v2.3.0.tar.gz/doc/license.html
Changed
@@ -21,7 +21,7 @@ <div id="mid"> <div id="main"> <pre> -Copyright (c) 2005-2018, 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
View file
_service:tar_scm:v2.1.0.tar.gz/doc/userguide.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/userguide.txt
Changed
@@ -1,7 +1,7 @@ uthash User Guide ================= Troy D. Hanson, Arthur O'Dwyer -v2.1.0, December 2018 +v2.3.0, February 2021 To download uthash, follow this link back to the https://github.com/troydhanson/uthashGitHub 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 in10; - 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, namesi); s->id = i; - HASH_ADD_STR( users, name, s ); + HASH_ADD_STR(users, name, s); }
View file
_service:tar_scm:v2.1.0.tar.gz/doc/utarray.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/utarray.txt
Changed
@@ -1,7 +1,7 @@ utarray: dynamic array macros for C =================================== Troy D. Hanson <tdh@tkhanson.net> -v2.1.0, December 2018 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthashGitHub project page. @@ -345,9 +345,11 @@ while `utarray_init` and `utarray_done` can be used if the UT_array is already allocated and just needs to be initialized or have its internal resources freed. -2. `utarray_reserve` takes the "delta" of elements to reserve (not the total - desired capacity of the array-- this differs from the C++ STL "reserve" notion) -3. `utarray_sort` expects a comparison function having the usual `strcmp` -like + +2. `utarray_reserve` takes the "delta" of elements to reserve, not the total + desired capacity of the array. This differs from the C++ STL "reserve" notion. + +3. `utarray_sort` expects a comparison function having the usual `strcmp`-like convention where it accepts two elements (a and b) and returns a negative value if a precedes b, 0 if a and b sort equally, and positive if b precedes a. This is an example of a comparison function: @@ -370,4 +372,12 @@ For this reason, it's usually better to refer to an element by its integer 'index' in code whose duration may include element insertion. +6. To override the default out-of-memory handling behavior (which calls `exit(-1)`), + override the `utarray_oom()` macro before including `utarray.h`. + For example, + + #define utarray_oom() do { longjmp(error_handling_location); } while (0) + ... + #include "utarray.h" + // vim: set nowrap syntax=asciidoc:
View file
_service:tar_scm:v2.1.0.tar.gz/doc/utlist.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/utlist.txt
Changed
@@ -1,7 +1,7 @@ utlist: linked list macros for C structures =========================================== Troy D. Hanson <tdh@tkhanson.net> -v2.1.0, December 2018 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthashGitHub project page.
View file
_service:tar_scm:v2.1.0.tar.gz/doc/utringbuffer.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/utringbuffer.txt
Changed
@@ -1,7 +1,7 @@ utringbuffer: dynamic ring-buffer macros for C ============================================== Arthur O'Dwyer <arthur.j.odwyer@gmail.com> -v2.1.0, December 2018 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthashGitHub project page.
View file
_service:tar_scm:v2.1.0.tar.gz/doc/utstack.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/utstack.txt
Changed
@@ -1,7 +1,7 @@ utstack: intrusive stack macros for C ===================================== Arthur O'Dwyer <arthur.j.odwyer@gmail.com> -v2.1.0, December 2018 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthashGitHub project page.
View file
_service:tar_scm:v2.1.0.tar.gz/doc/utstring.txt -> _service:tar_scm:v2.3.0.tar.gz/doc/utstring.txt
Changed
@@ -1,7 +1,7 @@ utstring: dynamic string macros for C ===================================== Troy D. Hanson <tdh@tkhanson.net> -v2.1.0, December 2018 +v2.3.0, February 2021 Here's a link back to the https://github.com/troydhanson/uthashGitHub project page. @@ -225,4 +225,15 @@ second argument, rather than the start position. You can emulate the position parameter by adding to the string start address and subtracting from its length. +Notes +~~~~~ + +1. To override the default out-of-memory handling behavior (which calls `exit(-1)`), + override the `utstring_oom()` macro before including `utstring.h`. + For example, + + #define utstring_oom() do { longjmp(error_handling_location); } while (0) + ... + #include "utstring.h" + // vim: set nowrap syntax=asciidoc:
View file
_service:tar_scm:v2.1.0.tar.gz/package.json -> _service:tar_scm:v2.3.0.tar.gz/package.json
Changed
@@ -24,5 +24,5 @@ "src/utstring.h" , - "version": "2.1.0" + "version": "2.3.0" }
View file
_service:tar_scm:v2.1.0.tar.gz/src/utarray.h -> _service:tar_scm:v2.3.0.tar.gz/src/utarray.h
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2018, 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.1.0 +#define UTARRAY_VERSION 2.3.0 #include <stddef.h> /* size_t */ #include <string.h> /* memset, etc */ @@ -38,8 +38,13 @@ #define UTARRAY_UNUSED #endif -#ifndef oom -#define oom() exit(-1) +#ifdef oom +#error "The name of macro 'oom' has been changed to 'utarray_oom'. Please update your code." +#define utarray_oom() oom() +#endif + +#ifndef utarray_oom +#define utarray_oom() exit(-1) #endif typedef void (ctor_f)(void *dst, const void *src); @@ -78,7 +83,9 @@ #define utarray_new(a,_icd) do { \ (a) = (UT_array*)malloc(sizeof(UT_array)); \ - if ((a) == NULL) oom(); \ + if ((a) == NULL) { \ + utarray_oom(); \ + } \ utarray_init(a,_icd); \ } while(0) @@ -92,7 +99,9 @@ char *utarray_tmp; \ while (((a)->i+(by)) > (a)->n) { (a)->n = ((a)->n ? (2*(a)->n) : 8); } \ utarray_tmp=(char*)realloc((a)->d, (a)->n*(a)->icd.sz); \ - if (utarray_tmp == NULL) oom(); \ + if (utarray_tmp == NULL) { \ + utarray_oom(); \ + } \ (a)->d=utarray_tmp; \ } \ } while(0) @@ -118,7 +127,7 @@ #define utarray_len(a) ((a)->i) #define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL) -#define _utarray_eltptr(a,j) ((a)->d + ((a)->icd.sz * (j))) +#define _utarray_eltptr(a,j) ((void*)((a)->d + ((a)->icd.sz * (j)))) #define utarray_insert(a,p,j) do { \ if ((j) > (a)->i) utarray_resize(a,j); \ @@ -216,15 +225,16 @@ #define utarray_find(a,v,cmp) bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp) #define utarray_front(a) (((a)->i) ? (_utarray_eltptr(a,0)) : NULL) -#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : ((((a)->i) > (utarray_eltidx(a,e)+1)) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL)) -#define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) > 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL)) +#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : (((a)->i != utarray_eltidx(a,e)+1) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL)) +#define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) != 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL)) #define utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL) -#define utarray_eltidx(a,e) (((char*)(e) >= (a)->d) ? (((char*)(e) - (a)->d)/(a)->icd.sz) : -1) +#define utarray_eltidx(a,e) (((char*)(e) - (a)->d) / (a)->icd.sz) /* last we pre-define a few icd for common utarrays of ints and strings */ static void utarray_str_cpy(void *dst, const void *src) { - char **_src = (char**)src, **_dst = (char**)dst; - *_dst = (*_src == NULL) ? NULL : strdup(*_src); + char *const *srcc = (char *const *)src; + char **dstc = (char**)dst; + *dstc = (*srcc == NULL) ? NULL : strdup(*srcc); } static void utarray_str_dtor(void *elt) { char **eltc = (char**)elt;
View file
_service:tar_scm:v2.1.0.tar.gz/src/uthash.h -> _service:tar_scm:v2.3.0.tar.gz/src/uthash.h
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2018, 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,12 +24,22 @@ #ifndef UTHASH_H #define UTHASH_H -#define UTHASH_VERSION 2.1.0 +#define UTHASH_VERSION 2.3.0 #include <string.h> /* memcmp, memset, strlen */ #include <stddef.h> /* ptrdiff_t */ #include <stdlib.h> /* exit */ +#if defined(HASH_DEFINE_OWN_STDINT) && HASH_DEFINE_OWN_STDINT +/* This codepath is provided for backward compatibility, but I plan to remove it. */ +#warning "HASH_DEFINE_OWN_STDINT is deprecated; please use HASH_NO_STDINT instead" +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +#elif defined(HASH_NO_STDINT) && HASH_NO_STDINT +#else +#include <stdint.h> /* uint8_t, uint32_t */ +#endif + /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed @@ -62,23 +72,6 @@ } while (0) #endif -/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */ -#if defined(_WIN32) -#if defined(_MSC_VER) && _MSC_VER >= 1600 -#include <stdint.h> -#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__) -#include <stdint.h> -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif -#elif defined(__GNUC__) && !defined(__VXWORKS__) -#include <stdint.h> -#else -typedef unsigned int uint32_t; -typedef unsigned char uint8_t; -#endif - #ifndef uthash_malloc #define uthash_malloc(sz) malloc(sz) /* malloc fcn */ #endif @@ -92,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 @@ -144,7 +134,7 @@ /* calculate the element whose hash handle address is hhp */ #define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) /* calculate the hash handle from element address elp */ -#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle *)(((char*)(elp)) + ((tbl)->hho))) +#define HH_FROM_ELMT(tbl,elp) ((UT_hash_handle*)(void*)(((char*)(elp)) + ((tbl)->hho))) #define HASH_ROLLBACK_BKT(hh, head, itemptrhh) \ do { \ @@ -158,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) \ @@ -175,9 +165,12 @@ #define HASH_FIND(hh,head,keyptr,keylen,out) \ do { \ - unsigned _hf_hashv; \ - HASH_VALUE(keyptr, keylen, _hf_hashv); \ - HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + (out) = NULL; \ + if (head) { \ + unsigned _hf_hashv; \ + HASH_VALUE(keyptr, keylen, _hf_hashv); \ + HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \ + } \ } while (0) #ifdef HASH_BLOOM @@ -405,7 +398,7 @@ do { \ IF_HASH_NONFATAL_OOM( int _ha_oomed = 0; ) \ (add)->hh.hashv = (hashval); \ - (add)->hh.key = (char*) (keyptr); \ + (add)->hh.key = (const void*) (keyptr); \ (add)->hh.keylen = (unsigned) (keylen_in); \ if (!(head)) { \ (add)->hh.next = NULL; \ @@ -519,7 +512,8 @@ * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG -#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) +#include <stdio.h> /* fprintf, stderr */ +#define HASH_OOPS(...) do { fprintf(stderr, __VA_ARGS__); exit(-1); } while (0) #define HASH_FSCK(hh,head,where) \ do { \ struct UT_hash_handle *_thh; \ @@ -586,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 { \ @@ -691,7 +678,8 @@ case 4: _hj_i += ( (unsigned)_hj_key3 << 24 ); /* FALLTHROUGH */ \ case 3: _hj_i += ( (unsigned)_hj_key2 << 16 ); /* FALLTHROUGH */ \ case 2: _hj_i += ( (unsigned)_hj_key1 << 8 ); /* FALLTHROUGH */ \ - case 1: _hj_i += _hj_key0; \ + case 1: _hj_i += _hj_key0; /* FALLTHROUGH */ \ + default: ; \ } \ HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ } while (0) @@ -739,6 +727,8 @@ case 1: hashv += *_sfh_key; \ hashv ^= hashv << 10; \ hashv += hashv >> 1; \ + break; \ + default: ; \ } \ \ /* Force "avalanching" of final 127 bits */ \ @@ -750,87 +740,6 @@ hashv += hashv >> 6; \ } while (0) -#ifdef HASH_USING_NO_STRICT_ALIASING -/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads. - * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error. - * MurmurHash uses the faster approach only on CPU's where we know it's safe. - * - * Note the preprocessor built-in defines can be emitted using: - * - * gcc -m64 -dM -E - < /dev/null (on gcc) - * cc -## a.c (where a.c is a simple test file) (Sun Studio) - */ -#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86)) -#define MUR_GETBLOCK(p,i) pi -#else /* non intel */ -#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) -#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) -#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) -#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) -#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) -#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) -#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) -#else /* assume little endian non-intel */ -#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24)) -#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16)) -#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8)) -#endif -#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)i) : \ - (MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \ - (MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \ - MUR_ONE_THREE(p)))) -#endif -#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r)))) -#define MUR_FMIX(_h) \ -do { \ - _h ^= _h >> 16; \
View file
_service:tar_scm:v2.1.0.tar.gz/src/utlist.h -> _service:tar_scm:v2.3.0.tar.gz/src/utlist.h
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2007-2018, 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.1.0 +#define UTLIST_VERSION 2.3.0 #include <assert.h>
View file
_service:tar_scm:v2.1.0.tar.gz/src/utringbuffer.h -> _service:tar_scm:v2.3.0.tar.gz/src/utringbuffer.h
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2018, 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.1.0 +#define UTRINGBUFFER_VERSION 2.3.0 #include <stdlib.h> #include <string.h>
View file
_service:tar_scm:v2.1.0.tar.gz/src/utstack.h -> _service:tar_scm:v2.3.0.tar.gz/src/utstack.h
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2018, 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.1.0 +#define UTSTACK_VERSION 2.3.0 /* * This file contains macros to manipulate a singly-linked list as a stack.
View file
_service:tar_scm:v2.1.0.tar.gz/src/utstring.h -> _service:tar_scm:v2.3.0.tar.gz/src/utstring.h
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2008-2018, 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.1.0 +#define UTSTRING_VERSION 2.3.0 #include <stdlib.h> #include <string.h> @@ -39,8 +39,13 @@ #define UTSTRING_UNUSED #endif -#ifndef oom -#define oom() exit(-1) +#ifdef oom +#error "The name of macro 'oom' has been changed to 'utstring_oom'. Please update your code." +#define utstring_oom() oom() +#endif + +#ifndef utstring_oom +#define utstring_oom() exit(-1) #endif typedef struct { @@ -54,7 +59,9 @@ if (((s)->n - (s)->i) < (size_t)(amt)) { \ char *utstring_tmp = (char*)realloc( \ (s)->d, (s)->n + (amt)); \ - if (utstring_tmp == NULL) oom(); \ + if (!utstring_tmp) { \ + utstring_oom(); \ + } \ (s)->d = utstring_tmp; \ (s)->n += (amt); \ } \ @@ -81,9 +88,11 @@ #define utstring_new(s) \ do { \ - (s) = (UT_string*)malloc(sizeof(UT_string)); \ - if (!(s)) oom(); \ - utstring_init(s); \ + (s) = (UT_string*)malloc(sizeof(UT_string)); \ + if (!(s)) { \ + utstring_oom(); \ + } \ + utstring_init(s); \ } while(0) #define utstring_renew(s) \
View file
_service:tar_scm:v2.1.0.tar.gz/tests/Makefile -> _service:tar_scm:v2.3.0.tar.gz/tests/Makefile
Changed
@@ -12,7 +12,7 @@ test66 test67 test68 test69 test70 test71 test72 test73 \ test74 test75 test76 test77 test78 test79 test80 test81 \ test82 test83 test84 test85 test86 test87 test88 test89 \ - test90 test91 test92 test93 test94 test95 + test90 test91 test92 test93 test94 test95 test96 CFLAGS += -I$(HASHDIR) #CFLAGS += -DHASH_BLOOM=16 #CFLAGS += -O2 @@ -34,9 +34,6 @@ TEST_TARGET=run_tests TESTS=./do_tests -# These flags are required in order to build with -DHASH_FUNCTION=HASH_MUR. -MUR_CFLAGS = -DHASH_USING_NO_STRICT_ALIASING -fno-strict-aliasing - # detect Cygwin ifneq ($(strip $(shell $(CC) -v 2>&1 |grep "cygwin")),) TESTS=./do_tests.cygwin @@ -74,17 +71,15 @@ $(MAKE) all HASH_PEDANTIC=1 cplusplus: - CC=$(CXX) $(MAKE) all + CC="$(CXX) -x c++" $(MAKE) all thorough: $(MAKE) clean && $(MAKE) all EXTRA_CFLAGS='-pedantic' $(MAKE) clean && $(MAKE) all EXTRA_CFLAGS='-pedantic -DHASH_BLOOM=16' $(MAKE) clean && $(MAKE) tests_only EXTRA_CFLAGS='-pedantic -DHASH_BLOOM=16 -DHASH_DEBUG -DNO_DECLTYPE' - $(MAKE) clean && $(MAKE) tests_only EXTRA_CFLAGS='-pedantic -DHASH_USING_NO_STRICT_ALIASING -fno-strict-aliasing -DHASH_FUNCTION=HASH_MUR' - $(MAKE) clean && CC=$(CXX) $(MAKE) all EXTRA_CFLAGS='-pedantic' - $(MAKE) clean && CC=$(CXX) $(MAKE) all EXTRA_CFLAGS='-pedantic -DHASH_BLOOM=16' - $(MAKE) clean && CC=$(CXX) $(MAKE) tests_only EXTRA_CFLAGS='-pedantic -DHASH_BLOOM=16 -DHASH_DEBUG -DNO_DECLTYPE' - $(MAKE) clean && CC=$(CXX) $(MAKE) tests_only EXTRA_CFLAGS='-pedantic -DHASH_USING_NO_STRICT_ALIASING -fno-strict-aliasing -DHASH_FUNCTION=HASH_MUR' + $(MAKE) clean && CC="$(CXX) -x c++" $(MAKE) all EXTRA_CFLAGS='-pedantic' + $(MAKE) clean && CC="$(CXX) -x c++" $(MAKE) all EXTRA_CFLAGS='-pedantic -DHASH_BLOOM=16' + $(MAKE) clean && CC="$(CXX) -x c++" $(MAKE) tests_only EXTRA_CFLAGS='-pedantic -DHASH_BLOOM=16 -DHASH_DEBUG -DNO_DECLTYPE' example: example.c $(HASHDIR)/uthash.h $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(@).c @@ -94,7 +89,7 @@ @$(MKGITIGN) hashscan : $(HASHDIR)/uthash.h - $(CC) $(CPPFLAGS) $(CFLAGS) $(MUR_CFLAGS) $(LDFLAGS) -o $@ $(@).c + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(@).c @$(MKGITIGN) sleep_test : $(HASHDIR)/uthash.h @@ -108,7 +103,6 @@ $(CC) $(CPPFLAGS) $(CFLAGS) -DHASH_FUNCTION=HASH_OAT $(LDFLAGS) -o keystat.OAT keystat.c $(CC) $(CPPFLAGS) $(CFLAGS) -DHASH_FUNCTION=HASH_SAX $(LDFLAGS) -o keystat.SAX keystat.c $(CC) $(CPPFLAGS) $(CFLAGS) -DHASH_FUNCTION=HASH_SFH $(LDFLAGS) -o keystat.SFH keystat.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(MUR_CFLAGS) -DHASH_FUNCTION=HASH_MUR $(LDFLAGS) -o keystat.MUR keystat.c run_tests: $(PROGS) perl $(TESTS)
View file
_service:tar_scm:v2.1.0.tar.gz/tests/README -> _service:tar_scm:v2.3.0.tar.gz/tests/README
Changed
@@ -7,7 +7,7 @@ test3: make 10-item hash, delete items with even keys, print others test4: 10 structs have dual hash handles, separate keys test5: 10 structs have dual hash handles, lookup evens by alt key -test6: test alt malloc macros (and alt memcmp macro) +test6: test alt malloc macros (and alt key-comparison macro) test7: test alt malloc macros with 1000 structs so bucket expansion occurs test8: test num_items counter in UT_hash_handle test9: test "find" after bucket expansion @@ -89,10 +89,15 @@ test85: test HASH_OVERHEAD on null and non null hash test86: test *_APPEND_ELEM / *_PREPEND_ELEM (Thilo Schulz) test87: test HASH_ADD_INORDER() macro (Thilo Schulz) -test88: test alt memcmp and strlen macros +test88: test alt key-comparison and strlen macros test89: test code from the tinydtls project test90: regression-test HASH_ADD_KEYPTR_INORDER (IronBug) test91: test LL_INSERT_INORDER etc. +test92: HASH_NONFATAL_OOM +test93: alt_fatal +test94: utlist with fields named other than 'next' and 'prev' +test95: utstack +test96: HASH_FUNCTION + HASH_KEYCMP Other Make targets ================================================================================
View file
_service:tar_scm:v2.1.0.tar.gz/tests/all_funcs -> _service:tar_scm:v2.3.0.tar.gz/tests/all_funcs
Changed
@@ -11,4 +11,3 @@ make clean tests_only EXTRA_CFLAGS='-DHASH_FUNCTION=HASH_OAT'; proceed make clean tests_only EXTRA_CFLAGS='-DHASH_FUNCTION=HASH_SAX'; proceed make clean tests_only EXTRA_CFLAGS='-DHASH_FUNCTION=HASH_SFH'; proceed -make clean tests_only EXTRA_CFLAGS='-DHASH_FUNCTION=HASH_MUR -DHASH_USING_NO_STRICT_ALIASING -fno-strict-aliasing'
View file
_service:tar_scm:v2.1.0.tar.gz/tests/do_tests.mingw -> _service:tar_scm:v2.3.0.tar.gz/tests/do_tests.mingw
Changed
@@ -5,7 +5,7 @@ for f in test*.exe do t=`echo $f | sed s/.exe//` - `$f > $t.out` + "./$f" > "$t.out" diff -qb "$t.out" "$t.ans" if $? -eq 1 then
View file
_service:tar_scm:v2.1.0.tar.gz/tests/example.c -> _service:tar_scm:v2.3.0.tar.gz/tests/example.c
Changed
@@ -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) @@ -77,10 +77,10 @@ HASH_SORT(users, id_sort); } -int main(int argc, char *argv) +int main() { char in10; - 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; } }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/hashscan.c -> _service:tar_scm:v2.3.0.tar.gz/tests/hashscan.c
Changed
@@ -1,5 +1,5 @@ /* -Copyright (c) 2005-2018, 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 @@ -28,8 +28,8 @@ #include <sys/stat.h> #include <fcntl.h> #include <inttypes.h> +#include <sys/types.h> /* on OSX, must come before ptrace.h */ #include <sys/ptrace.h> -#include <sys/types.h> #include <unistd.h> #include <sys/wait.h> #include <assert.h> @@ -39,6 +39,11 @@ #include <vm/vm.h> /* VM_PROT_* flags */ #endif +#if defined(PT_ATTACH) && !defined(PTRACE_ATTACH) +#define PTRACE_ATTACH PT_ATTACH +#define PTRACE_DETACH PT_DETACH +#endif + /* need this defined so offsetof can give us bloom offsets in UT_hash_table */ #define HASH_BLOOM 16 #include "uthash.h" @@ -71,9 +76,8 @@ #define SAX 4 #define FNV 5 #define OAT 6 -#define MUR 7 -#define NUM_HASH_FUNCS 8 /* includes id 0, the non-function */ -const char *hash_fcns = {"???","JEN","BER","SFH","SAX","FNV","OAT","MUR"}; +#define NUM_HASH_FUNCS 7 /* includes id 0, the non-function */ +const char *hash_fcns = {"???","JEN","BER","SFH","SAX","FNV","OAT"}; /* given a peer key/len/hashv, reverse engineer its hash function */ static int infer_hash_function(char *key, size_t keylen, uint32_t hashv) @@ -104,10 +108,6 @@ if (ohashv == hashv) { return OAT; } - HASH_MUR(key,keylen,ohashv); - if (ohashv == hashv) { - return MUR; - } return 0; } @@ -172,7 +172,8 @@ UT_hash_handle hh; size_t i, bloom_len, bloom_bitlen, bloom_on_bits=0,bloom_off_bits=0; char *peer_tbl, *peer_bloom_sig, *peer_bloom_nbits, *peer_bloombv_ptr, - *peer_bloombv, *peer_bkts, *peer_key, *peer_hh, *key=NULL; + *peer_bloombv, *peer_bkts, *peer_hh, *key=NULL; + const char *peer_key; const char *hash_fcn = NULL; unsigned char *bloombv=NULL; static int fileno=0; @@ -215,11 +216,11 @@ /* got the table. how about the buckets */ peer_bkts = (char*)tbl->buckets; - vvv("reading buckets at peer %p\n", (void*)peer_bkts); + vvv("reading %u buckets at peer %p\n", tbl->num_buckets, (void*)peer_bkts); bkts = (UT_hash_bucket*)malloc(sizeof(UT_hash_bucket)*tbl->num_buckets); if (bkts == NULL) { fprintf(stderr, "out of memory\n"); - exit(-1); + goto done; } #ifdef __FreeBSD__ if (read_mem(bkts, pid, (void *)peer_bkts, sizeof(UT_hash_bucket)*tbl->num_buckets) != 0) { @@ -255,7 +256,7 @@ goto done; } peer_hh = (char*)hh.hh_next; - peer_key = (char*)(hh.key); + peer_key = (const char*)(hh.key); /* malloc space to read the key, and read it */ if ( (key = (char*)malloc(sizeof(hh.keylen))) == NULL) { fprintf(stderr, "out of memory\n"); @@ -575,7 +576,7 @@ /* attach to the target process and wait for it to suspend */ vv("attaching to peer\n"); - if (ptrace(PTRACE_ATTACH,pid,NULL,NULL) == -1) { + if (ptrace(PTRACE_ATTACH, pid, NULL, 0) == -1) { fprintf(stderr,"failed to attach to %u: %s\n", (unsigned)pid, strerror(errno)); exit(-1); } @@ -637,7 +638,7 @@ die: vv("detaching and resuming peer\n"); - if (ptrace(PTRACE_DETACH, pid, NULL, NULL) == -1) { + if (ptrace(PTRACE_DETACH, pid, NULL, 0) == -1) { fprintf(stderr,"failed to detach from %u: %s\n", (unsigned)pid, strerror(errno)); } return 0;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/keystats -> _service:tar_scm:v2.3.0.tar.gz/tests/keystats
Changed
@@ -12,9 +12,11 @@ usage if ((@ARGV == 0) or ($ARGV0 eq '-h')); -my @exes = glob "$FindBin::Bin/keystat.???"; +my @exes = glob "'$FindBin::Bin/keystat.???'"; + my %stats; for my $exe (@exes) { + $exe =~ s/\ /\\ /g; $stats{$exe} = `$exe @ARGV`; delete $stats{$exe} if ($? != 0); # omit hash functions that fail to produce stats (nx) }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/lru_cache/main.c -> _service:tar_scm:v2.3.0.tar.gz/tests/lru_cache/main.c
Changed
@@ -98,7 +98,7 @@ pthread_exit(NULL); } -int main(void) +int main() { int rv; struct foo_cache *cache = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/sleep_test.c -> _service:tar_scm:v2.3.0.tar.gz/tests/sleep_test.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test1.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test1.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test10.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test10.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle alth; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL, *altusers=NULL; @@ -47,5 +47,8 @@ HASH_FIND(alth,altusers,&i,sizeof(int),tmp); printf("%d %s in alth\n", i, (tmp != NULL) ? "found" : "not found"); + HASH_CLEAR(hh, users); + HASH_CLEAR(alth, altusers); + return 0; }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test11.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test11.c
Changed
@@ -25,7 +25,7 @@ return strcmp(a->boy_name,b->boy_name); } -int main(int argc,char *argv) +int main() { name_rec *name, *names=NULL; char linebufBUFLEN;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test12.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test12.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } person_t; -int main(int argc, char*argv) +int main() { person_t *people=NULL, *person; const char **name;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test13.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test13.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test14.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test14.c
Changed
@@ -14,7 +14,7 @@ UT_hash_handle hh; } name_rec; -int main(int argc,char *argv) +int main() { name_rec *name, *names=NULL; char linebufBUFLEN;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test15.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test15.c
Changed
@@ -10,7 +10,7 @@ }; -int main(int argc, char *argv) +int main() { const char **n, *names = { "joe", "bob", "betty", NULL }; struct my_struct *s, *tmp, *users = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test16.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test16.c
Changed
@@ -17,7 +17,7 @@ }; -int main(int argc, char *argv) +int main() { struct my_event *e, ev, *events = NULL; unsigned keylen;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test17.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test17.c
Changed
@@ -16,7 +16,7 @@ return (a->id - b->id); } -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test18.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test18.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test19.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test19.c
Changed
@@ -29,7 +29,7 @@ return (a->id < b->id) ? 1 : -1; } -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL, *altusers=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test2.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test2.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test20.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test20.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle hh; }; -int main(int argc, char *argv) +int main() { struct my_struct *s, *t, *bins = NULL; char binary5 = {'\3','\1','\4','\1','\6'};
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test21.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test21.c
Changed
@@ -13,7 +13,7 @@ UT_hash_handle hh; } record_t; -int main(int argc, char *argv) +int main() { record_t l, *p, *r, *tmp, *records = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test22.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test22.c
Changed
@@ -18,7 +18,7 @@ int text; } lookup_key_t; -int main(int argc, char *argv) +int main() { unsigned keylen; msg_t *msg, *tmp, *msgs = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test24.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test24.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test25.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test25.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; int count;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test26.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test26.c
Changed
@@ -17,7 +17,7 @@ return strcmp(a->bname,b->bname); } -int main(int argc, char *argv) +int main() { el *name, *elt, *tmp, etmp; el *head = NULL; /* important- initialize to NULL! */
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test27.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test27.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els10, *e;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test28.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test28.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els10, *e;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test29.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test29.c
Changed
@@ -17,7 +17,7 @@ return strcmp(a->bname,b->bname); } -int main(int argc, char *argv) +int main() { el *name, *tmp; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test3.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test3.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test30.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test30.c
Changed
@@ -17,7 +17,7 @@ return strcmp(a->bname,b->bname); } -int main(int argc, char *argv) +int main() { el *name, *tmp; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test31.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test31.c
Changed
@@ -17,7 +17,7 @@ return strcmp(a->bname,b->bname); } -int main(int argc, char *argv) +int main() { el *name, *tmp; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test32.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test32.c
Changed
@@ -10,7 +10,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { el *name, *tmp; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test33.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test33.c
Changed
@@ -17,7 +17,7 @@ return strcmp(a->bname,b->bname); } -int main(int argc, char *argv) +int main() { el *name, *tmp; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test34.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test34.c
Changed
@@ -10,7 +10,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { el *name, *tmp; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test35.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test35.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } elt; -int main(int argc,char *argv) +int main() { int i; elt *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test36.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test36.c
Changed
@@ -22,7 +22,7 @@ return (a->id - b->id); } -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL, *ausers=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test37.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test37.c
Changed
@@ -17,7 +17,7 @@ return (a->id - b->id); } -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL, *ausers=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test38.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test38.c
Changed
@@ -7,7 +7,7 @@ UT_hash_handle hh; }; -int main(void) +int main() { struct test_t *tests=NULL, *test; int a, b;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test4.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test4.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle alth; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL, *altusers=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test40.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test40.c
Changed
@@ -10,7 +10,7 @@ }; -int main(int argc, char *argv) +int main() { const char **n, *names = { "joe", "bob", "betty", NULL }; struct my_struct *s, *tmp, *users = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test41.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test41.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test42.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test42.c
Changed
@@ -11,7 +11,7 @@ return a->id - b->id; } -int main(int argc, char *argv) +int main() { int i; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test44.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test44.c
Changed
@@ -1,10 +1,10 @@ #include <stdio.h> #include "utarray.h" -static int reverse(const void *a,const void*b) +static int reverse(const void *a, const void *b) { - int _a = *(int*)a; - int _b = *(int*)b; + int _a = *(const int*)a; + int _b = *(const int*)b; return _b - _a; }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test46.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test46.c
Changed
@@ -3,15 +3,15 @@ static int strsort(const void *_a, const void *_b) { - char *a = *(char**)_a; - char *b = *(char**)_b; + const char *a = *(const char* const *)_a; + const char *b = *(const char* const *)_b; return strcmp(a,b); } static int revsort(const void *_a, const void *_b) { - char *a = *(char**)_a; - char *b = *(char**)_b; + const char *a = *(const char* const *)_a; + const char *b = *(const char* const *)_b; return strcmp(b,a); }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test5.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test5.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle alth; } example_user_t; -int main(int argc,char *argv) +int main() { int i,j; example_user_t *user, *tmp, *users=NULL, *altusers=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test52.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test52.c
Changed
@@ -9,7 +9,8 @@ static void intchar_copy(void *_dst, const void *_src) { - intchar_t *dst = (intchar_t*)_dst, *src = (intchar_t*)_src; + intchar_t *dst = (intchar_t*)_dst; + const intchar_t *src = (const intchar_t*)_src; dst->a = src->a; dst->s = (src->s != NULL) ? strdup(src->s) : NULL; }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test56.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test56.c
Changed
@@ -25,7 +25,7 @@ return strcmp(a->bname,b->bname); } -int main(int argc, char *argv) +int main() { el *name, *elt, *tmp, etmp; int i;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test58.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test58.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; unsigned c;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test59.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test59.c
Changed
@@ -11,7 +11,7 @@ UT_hash_handle hh; } item_t; -int main(int argc, char *argvp) +int main() { item_t *item1, *item2, *tmp1, *tmp2; item_t *items=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test6.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test6.c
Changed
@@ -7,15 +7,16 @@ /* Set up macros for alternative malloc/free functions */ #undef uthash_malloc #undef uthash_free -#undef uthash_memcmp #undef uthash_strlen #undef uthash_bzero #define uthash_malloc(sz) alt_malloc(sz) #define uthash_free(ptr,sz) alt_free(ptr,sz) -#define uthash_memcmp(a,b,n) alt_memcmp(a,b,n) #define uthash_strlen(s) ..fail_to_compile.. #define uthash_bzero(a,n) alt_bzero(a,n) +#undef HASH_KEYCMP +#define HASH_KEYCMP(a,b,n) alt_keycmp(a,b,n) + typedef struct example_user_t { int id; int cookie; @@ -41,10 +42,10 @@ free(ptr); } -static int alt_memcmp_count = 0; -static int alt_memcmp(void *a, void *b, size_t n) +static int alt_keycmp_count = 0; +static int alt_keycmp(const void *a, const void *b, size_t n) { - ++alt_memcmp_count; + ++alt_keycmp_count; return memcmp(a,b,n); } @@ -78,7 +79,7 @@ #define memcmp ..fail_to_compile.. #define strlen ..fail_to_compile.. -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL; @@ -115,7 +116,7 @@ #else assert(alt_bzero_count == 2); #endif - assert(alt_memcmp_count == 10); + assert(alt_keycmp_count == 10); assert(alt_malloc_balance == 0); return 0; }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test60.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test60.c
Changed
@@ -11,7 +11,7 @@ UT_hash_handle hh; } item_t; -int main(int argc, char *argvp) +int main() { item_t *item1, *item2, *tmp1, *tmp2; item_t *items=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test61.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test61.c
Changed
@@ -3,8 +3,8 @@ static int strsort(const void *_a, const void *_b) { - const char *a = *(const char**)_a; - const char *b = *(const char**)_b; + const char *a = *(const char* const *)_a; + const char *b = *(const char* const *)_b; return strcmp(a,b); }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test62.ans -> _service:tar_scm:v2.3.0.tar.gz/tests/test62.ans
Changed
@@ -1,20 +0,0 @@ -al aligned (y): y -u1 aligned (n): n -u2 aligned (n): n -u3 aligned (n): n - -al plus1 (n): n -u1 plus1 (y): y -u2 plus1 (n): n -u3 plus1 (n): n - -al plus2 (n): n -u1 plus2 (n): n -u2 plus2 (y): y -u3 plus2 (n): n - -al plus3 (n): n -u1 plus3 (n): n -u2 plus3 (n): n -u3 plus3 (y): y -
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test62.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test62.c
Changed
@@ -1,90 +1,80 @@ -#include <stdio.h> + +#include <assert.h> #include <stdlib.h> -#include <inttypes.h> -#include "uthash.h" -#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 3UL) == 0UL) -#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 3UL) == 1UL) -#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) -#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) +#define HASH_FUNCTION(s, len, hashv) (hashv) = TrivialHash((const char *)s, len) +#include "uthash.h" -#define yn(rc) ((rc!=0U)?"y":"n") -int main(int argc,char*argv) +unsigned int TrivialHash(const char *s, size_t len) { - unsigned rc; - char *c = (char *)malloc(8UL); - if (c == NULL) { - exit(-1); + unsigned int h = 0; + size_t i; + for (i=0; i < len; ++i) { + h += (unsigned char)si; } - *(c+0) = 0x00; - unsigned *al = (unsigned*)(c+0); - *(c+1) = 0x01; - unsigned *u1 = (unsigned*)(c+1); - *(c+2) = 0x02; - unsigned *u2 = (unsigned*)(c+2); - *(c+3) = 0x03; - unsigned *u3 = (unsigned*)(c+3); - *(c+4) = 0x04; - *(c+5) = 0x05; - *(c+6) = 0x06; - *(c+7) = 0x07; + return h; +} + +struct test_t { + int a; + int b; + UT_hash_handle hh; +}; + +struct test_t *make_test(int value) +{ + struct test_t *test = (struct test_t *)malloc(sizeof *test); + assert(test != NULL); + test->a = value; + return test; +} + +int main() +{ + struct test_t *tests = NULL; + struct test_t *test = NULL; + int x; + unsigned int h; + + x = 0x0042; + HASH_VALUE(&x, sizeof x, h); + assert(h == 0x42); + + x = 0x4002; + HASH_VALUE(&x, sizeof x, h); + assert(h == 0x42); - /* ---------------------------------------- */ - /* test whether alignment is detected properly */ + test = make_test(0x0042); + HASH_ADD_INT(tests, a, test); + test = make_test(0x4002); + HASH_ADD_INT(tests, a, test); - rc = MUR_PLUS0_ALIGNED(al); - printf("al aligned (y): %s\n", yn(rc)); - rc = MUR_PLUS0_ALIGNED(u1); - printf("u1 aligned (n): %s\n", yn(rc)); - rc = MUR_PLUS0_ALIGNED(u2); - printf("u2 aligned (n): %s\n", yn(rc)); - rc = MUR_PLUS0_ALIGNED(u3); - printf("u3 aligned (n): %s\n", yn(rc)); - printf("\n"); + x = 0x4002; + test = NULL; + HASH_FIND_BYHASHVALUE(hh, tests, &x, sizeof x, 0x42, test); + assert(test != NULL); + assert(test->a == 0x4002); - rc = MUR_PLUS1_ALIGNED(al); - printf("al plus1 (n): %s\n", yn(rc)); - rc = MUR_PLUS1_ALIGNED(u1); - printf("u1 plus1 (y): %s\n", yn(rc)); - rc = MUR_PLUS1_ALIGNED(u2); - printf("u2 plus1 (n): %s\n", yn(rc)); - rc = MUR_PLUS1_ALIGNED(u3); - printf("u3 plus1 (n): %s\n", yn(rc)); - printf("\n"); + x = 0x0042; + test = NULL; + HASH_FIND_BYHASHVALUE(hh, tests, &x, sizeof x, 0x42, test); + assert(test != NULL); + assert(test->a == 0x0042); - rc = MUR_PLUS2_ALIGNED(al); - printf("al plus2 (n): %s\n", yn(rc)); - rc = MUR_PLUS2_ALIGNED(u1); - printf("u1 plus2 (n): %s\n", yn(rc)); - rc = MUR_PLUS2_ALIGNED(u2); - printf("u2 plus2 (y): %s\n", yn(rc)); - rc = MUR_PLUS2_ALIGNED(u3); - printf("u3 plus2 (n): %s\n", yn(rc)); - printf("\n"); + x = 0x4002; + test = NULL; + HASH_FIND_BYHASHVALUE(hh, tests, &x, sizeof x, 0x43, test); + assert(test == NULL); - rc = MUR_PLUS3_ALIGNED(al); - printf("al plus3 (n): %s\n", yn(rc)); - rc = MUR_PLUS3_ALIGNED(u1); - printf("u1 plus3 (n): %s\n", yn(rc)); - rc = MUR_PLUS3_ALIGNED(u2); - printf("u2 plus3 (n): %s\n", yn(rc)); - rc = MUR_PLUS3_ALIGNED(u3); - printf("u3 plus3 (y): %s\n", yn(rc)); - printf("\n"); + x = 0x0042; + test = NULL; + HASH_FIND_BYHASHVALUE(hh, tests, &x, sizeof x, 0x43, test); + assert(test == NULL); - /* ---------------------------------------- */ - /* test careful reassembly of an unaligned integer */ -#if 0 /* commented out since result is endian dependent */ - rc = MUR_GETBLOCK(al,0); - printf("%x\n", rc); - rc = MUR_GETBLOCK(u1,0); - printf("%x\n", rc); - rc = MUR_GETBLOCK(u2,0); - printf("%x\n", rc); - rc = MUR_GETBLOCK(u3,0); - printf("%x\n", rc); -#endif + x = 0x4003; + test = NULL; + HASH_FIND_BYHASHVALUE(hh, tests, &x, sizeof x, 0x42, test); + assert(test == NULL); - free(c); - return 0; + HASH_CLEAR(hh, tests); }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test63.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test63.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els10, *e;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test64.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test64.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els10, *e;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test66.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test66.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } person_t; -int main(int argc, char*argv) +int main() { person_t *people=NULL, *person; const char **name;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test68.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test68.c
Changed
@@ -7,7 +7,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els20, *e, *tmp;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test69.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test69.c
Changed
@@ -7,7 +7,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els26, *e, *tmp;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test7.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test7.c
Changed
@@ -9,7 +9,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test70.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test70.c
Changed
@@ -7,7 +7,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els20, *e, *tmp;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test71.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test71.c
Changed
@@ -7,7 +7,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els26, *e, *tmp;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test72.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test72.c
Changed
@@ -7,7 +7,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els20, *e, *tmp, *tmp2;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test73.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test73.c
Changed
@@ -7,7 +7,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; el els26, *e, *tmp, *tmp2;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test76.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test76.c
Changed
@@ -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,
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test77.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test77.c
Changed
@@ -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),
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test78.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test78.c
Changed
@@ -6,7 +6,7 @@ struct el *Next, *Prev; } el; -int main(int argc, char *argv) +int main() { int i; el els10, *e;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test79.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test79.c
Changed
@@ -17,7 +17,7 @@ } } -int main(int argc, char *argv) +int main() { hs_t *hs_head=NULL, *tmp, *replaced=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test8.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test8.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test83.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test83.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } person_t; -int main(int argc, char*argv) +int main() { person_t *people=NULL, *person, *new_person, *tmp; const char **name;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test84.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test84.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } person_t; -int main(int argc, char*argv) +int main() { person_t *people=NULL, *person, *new_person, *tmp; const char **name;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test85.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test85.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test86.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test86.c
Changed
@@ -6,7 +6,7 @@ struct el *next, *prev; } el; -int main(int argc, char *argv) +int main() { int i; int count;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test88.ans -> _service:tar_scm:v2.3.0.tar.gz/tests/test88.ans
Changed
@@ -9,22 +9,22 @@ alt_strlen alt_strlen alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp alt_strlen -alt_memcmp +alt_keycmp
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test88.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test88.c
Changed
@@ -8,9 +8,9 @@ /* This is mostly a copy of test6.c. */ -#undef uthash_memcmp +#undef HASH_KEYCMP #undef uthash_strlen -#define uthash_memcmp(a,b,n) alt_memcmp(a,b,n) +#define HASH_KEYCMP(a,b,n) alt_keycmp(a,b,n) #define uthash_strlen(s) alt_strlen(s) typedef struct example_user_t { @@ -19,9 +19,9 @@ UT_hash_handle hh; } example_user_t; -static int alt_memcmp(void *a, void *b, size_t n) +static int alt_keycmp(const void *a, const void *b, size_t n) { - puts("alt_memcmp"); + puts("alt_keycmp"); return memcmp(a,b,n); } @@ -31,7 +31,7 @@ return strlen(s); } -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test9.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test9.c
Changed
@@ -8,7 +8,7 @@ UT_hash_handle hh; } example_user_t; -int main(int argc,char *argv) +int main() { int i; example_user_t *user, *tmp, *users=NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test90.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test90.c
Changed
@@ -12,8 +12,8 @@ int sort_func(const struct item *a, const struct item *b) { - int va = *(int*)a->sort_field; - int vb = *(int*)b->sort_field; + int va = *(int*)(void*)a->sort_field; + int vb = *(int*)(void*)b->sort_field; return (va < vb) ? -1 : (va > vb); } @@ -33,7 +33,7 @@ p->sort_field_len = sizeof(int); p->sort_field = (unsigned char *)malloc(p->sort_field_len); - *(int*)p->sort_field = counter++; + *(int*)(void*)p->sort_field = counter++; HASH_ADD_KEYPTR_INORDER(hh, list, p->sort_field, p->sort_field_len, p, sort_func); } @@ -41,7 +41,7 @@ printf("filling in is ok\n"); HASH_ITER(hh, list, p, tmp) { - total += *(int*)p->sort_field; + total += *(int*)(void*)p->sort_field; HASH_DEL(list, p); free(p->sort_field); free(p);
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test91.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test91.c
Changed
@@ -11,7 +11,7 @@ return (a->score > b->score) ? -1 : (a->score < b->score); } -int main(int argc, char *argv) +int main() { int i; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test92.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test92.c
Changed
@@ -56,7 +56,7 @@ } } -int main(int argc, char *argv) +int main() { example_user_t *users = NULL; example_user_t *user = (example_user_t*)malloc(sizeof(example_user_t));
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test93.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test93.c
Changed
@@ -34,47 +34,44 @@ } static void alt_fatal(char const * s) { + (void)s; is_fatal = 1; 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(int argc, char *argv) +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 */ @@ -82,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) { @@ -107,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; - }
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test94.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test94.c
Changed
@@ -17,7 +17,7 @@ return -order_desc(a, b); } -int main(int argc, char *argv) +int main() { int i; el *head = NULL;
View file
_service:tar_scm:v2.1.0.tar.gz/tests/test95.c -> _service:tar_scm:v2.3.0.tar.gz/tests/test95.c
Changed
@@ -1,5 +1,5 @@ #include <assert.h> -#include <stdio.h> +#include <stddef.h> /* size_t, NULL */ #include "utstack.h" typedef struct el {
View file
_service:tar_scm:v2.3.0.tar.gz/tests/test96.ans
Added
@@ -0,0 +1,40 @@ +time 56 not found, inserting it +time 7 not found, inserting it +time 10 not found, inserting it +time 39 not found, inserting it +time 82 found with value 10 +time 15 found with value 39 +time 31 found with value 7 +time 26 not found, inserting it +time 51 found with value 39 +time 83 not found, inserting it +time 46 found with value 10 +time 92 found with value 56 +time 49 not found, inserting it +time 25 found with value 49 +time 80 found with value 56 +time 54 not found, inserting it +time 97 found with value 49 +time 9 not found, inserting it +time 34 found with value 10 +time 86 found with value 26 +time 87 found with value 39 +time 28 not found, inserting it +time 13 found with value 49 +time 91 found with value 7 +time 95 found with value 83 +time 63 found with value 39 +time 71 found with value 83 +time 100 found with value 28 +time 44 found with value 56 +time 42 found with value 54 +time 16 found with value 28 +time 32 found with value 56 +time 6 found with value 54 +time 85 found with value 49 +time 40 found with value 28 +time 20 found with value 56 +time 18 found with value 54 +time 99 found with value 39 +time 22 found with value 10 +time 1 found with value 49
View file
_service:tar_scm:v2.3.0.tar.gz/tests/test96.c
Added
@@ -0,0 +1,48 @@ +#include <stdio.h> +#include <stdlib.h> + +#define HASH_FUNCTION(a,n,hv) (hv = clockface_hash(*(const int*)(a))) +#define HASH_KEYCMP(a,b,n) clockface_neq(*(const int*)(a), *(const int*)(b)) + +#include "uthash.h" + +struct clockface { + int time; + UT_hash_handle hh; +}; + +int clockface_hash(int time) +{ + return (time % 4); +} + +int clockface_neq(int t1, int t2) +{ + return ((t1 % 12) != (t2 % 12)); +} + +int main() +{ + int random_data = { + 56, 7, 10, 39, 82, 15, 31, 26, 51, 83, + 46, 92, 49, 25, 80, 54, 97, 9, 34, 86, + 87, 28, 13, 91, 95, 63, 71, 100, 44, 42, + 16, 32, 6, 85, 40, 20, 18, 99, 22, 1 + }; + + struct clockface *times = NULL; + for (int i=0; i < 40; ++i) { + struct clockface *elt = (struct clockface *)malloc(sizeof(*elt)); + struct clockface *found = NULL; + elt->time = random_datai; + HASH_FIND_INT(times, &elt->time, found); + if (found) { + printf("time %d found with value %d\n", elt->time, found->time); + } else { + printf("time %d not found, inserting it\n", elt->time); + HASH_ADD_INT(times, time, elt); + } + } + + return 0; +}
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2