Parcourir la source

Merge pull request #59 from fperrad/astyle

Astyle
Troy D. Hanson il y a 10 ans
Parent
commit
1d63693690
92 fichiers modifiés avec 2686 ajouts et 1681 suppressions
  1. 4 1
      tests/Makefile
  2. 30 12
      tests/bloom_perf.c
  3. 5 2
      tests/emit_keys.c
  4. 35 21
      tests/example.c
  5. 519 443
      tests/hashscan.c
  6. 134 99
      tests/keystat.c
  7. 6 3
      tests/sleep_test.c
  8. 7 4
      tests/test1.c
  9. 10 5
      tests/test10.c
  10. 11 6
      tests/test11.c
  11. 11 6
      tests/test12.c
  12. 14 7
      tests/test13.c
  13. 11 5
      tests/test14.c
  14. 10 5
      tests/test15.c
  15. 10 5
      tests/test16.c
  16. 13 7
      tests/test17.c
  17. 9 6
      tests/test18.c
  18. 26 13
      tests/test19.c
  19. 13 7
      tests/test2.c
  20. 9 4
      tests/test20.c
  21. 12 7
      tests/test21.c
  22. 19 12
      tests/test22.c
  23. 56 34
      tests/test23.c
  24. 7 4
      tests/test24.c
  25. 36 17
      tests/test25.c
  26. 14 6
      tests/test26.c
  27. 36 17
      tests/test27.c
  28. 42 20
      tests/test28.c
  29. 13 5
      tests/test29.c
  30. 11 6
      tests/test3.c
  31. 10 4
      tests/test30.c
  32. 10 4
      tests/test31.c
  33. 10 4
      tests/test32.c
  34. 10 4
      tests/test33.c
  35. 10 4
      tests/test34.c
  36. 16 15
      tests/test35.c
  37. 16 11
      tests/test36.c
  38. 12 8
      tests/test37.c
  39. 22 19
      tests/test38.c
  40. 24 21
      tests/test39.c
  41. 7 4
      tests/test4.c
  42. 10 5
      tests/test40.c
  43. 23 8
      tests/test41.c
  44. 42 16
      tests/test42.c
  45. 121 66
      tests/test43.c
  46. 56 34
      tests/test44.c
  47. 31 19
      tests/test45.c
  48. 76 41
      tests/test46.c
  49. 2 1
      tests/test47.c
  50. 15 12
      tests/test48.c
  51. 15 12
      tests/test49.c
  52. 13 7
      tests/test5.c
  53. 16 11
      tests/test50.c
  54. 19 14
      tests/test51.c
  55. 32 23
      tests/test52.c
  56. 2 1
      tests/test53.c
  57. 2 1
      tests/test54.c
  58. 2 1
      tests/test55.c
  59. 18 8
      tests/test56.c
  60. 23 18
      tests/test57.c
  61. 10 6
      tests/test58.c
  62. 40 35
      tests/test59.c
  63. 18 9
      tests/test6.c
  64. 36 31
      tests/test60.c
  65. 43 36
      tests/test61.c
  66. 75 48
      tests/test62.c
  67. 29 9
      tests/test63.c
  68. 29 9
      tests/test64.c
  69. 19 16
      tests/test65.c
  70. 11 6
      tests/test66.c
  71. 20 17
      tests/test67.c
  72. 41 11
      tests/test68.c
  73. 45 12
      tests/test69.c
  74. 11 6
      tests/test7.c
  75. 41 11
      tests/test70.c
  76. 45 12
      tests/test71.c
  77. 41 11
      tests/test72.c
  78. 45 12
      tests/test73.c
  79. 7 8
      tests/test74.c
  80. 7 8
      tests/test75.c
  81. 10 14
      tests/test76.c
  82. 25 22
      tests/test77.c
  83. 36 17
      tests/test78.c
  84. 57 46
      tests/test79.c
  85. 11 6
      tests/test8.c
  86. 22 13
      tests/test80.c
  87. 22 13
      tests/test81.c
  88. 32 21
      tests/test82.c
  89. 14 6
      tests/test83.c
  90. 21 8
      tests/test84.c
  91. 14 11
      tests/test85.c
  92. 11 6
      tests/test9.c

+ 4 - 1
tests/Makefile

@@ -104,7 +104,10 @@ run_tests: $(PROGS)
 run_tests_mingw: $(PROGS)
 	/bin/sh do_tests.mingw
 
-.PHONY: clean
+astyle:
+	astyle -n --style=kr --indent-switches --add-brackets *.c
+
+.PHONY: clean astyle
 
 clean:	
 	rm -f $(UTILS) $(PLAT_UTILS) $(PROGS) test*.out keystat.??? example *.exe

+ 30 - 12
tests/bloom_perf.c

@@ -15,14 +15,17 @@ typedef struct name_rec {
     UT_hash_handle hh;
 } name_rec;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     name_rec *name, *names=NULL;
     char linebuf[BUFLEN];
     FILE *file;
     int i=0,j,nloops=3,loopnum=0,miss;
     struct timeval tv1,tv2;
     long elapsed_usec;
-    if (argc > 1) nloops = atoi(argv[1]);
+    if (argc > 1) {
+        nloops = atoi(argv[1]);
+    }
 
     if ( (file = fopen( "test14.dat", "r" )) == NULL ) {
         perror("can't open: ");
@@ -31,34 +34,49 @@ int main(int argc,char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         i++;
-        if ( (name = (name_rec*)malloc(sizeof(name_rec))) == NULL) exit(-1);
+        if ( (name = (name_rec*)malloc(sizeof(name_rec))) == NULL) {
+            exit(-1);
+        }
         strncpy(name->boy_name,linebuf,BUFLEN);
         HASH_ADD_STR(names,boy_name,name);
     }
 
-  again:
+again:
     if (fseek(file,0,SEEK_SET) == -1) {
-       fprintf(stderr,"fseek failed: %s\n", strerror(errno));
+        fprintf(stderr,"fseek failed: %s\n", strerror(errno));
     }
     j=0;
 
-    if (gettimeofday(&tv1,NULL) == -1) perror("gettimeofday: ");
+    if (gettimeofday(&tv1,NULL) == -1) {
+        perror("gettimeofday: ");
+    }
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         /* if we do 10 loops, the first has a 0% miss rate,
          * the second has a 10% miss rate, etc */
         miss = ((rand()*1.0/RAND_MAX) < (loopnum*1.0/nloops)) ? 1 : 0;
         /* generate a miss if we want one */
-        if (miss) { linebuf[0]++; if (linebuf[1] != '\0') linebuf[1]++; }
+        if (miss) {
+            linebuf[0]++;
+            if (linebuf[1] != '\0') {
+                linebuf[1]++;
+            }
+        }
         HASH_FIND_STR(names,linebuf,name);
-        if (name) j++;
+        if (name) {
+            j++;
+        }
+    }
+    if (gettimeofday(&tv2,NULL) == -1) {
+        perror("gettimeofday: ");
     }
-    if (gettimeofday(&tv2,NULL) == -1) perror("gettimeofday: ");
     elapsed_usec = ((tv2.tv_sec - tv1.tv_sec) * 1000000) + (tv2.tv_usec - tv1.tv_usec);
     printf("lookup on %d of %d (%.2f%%) names succeeded (%.2f usec)\n", j, i,
-       j*100.0/i, (double)(elapsed_usec));
-    if (++loopnum < nloops) goto again;
+           j*100.0/i, (double)(elapsed_usec));
+    if (++loopnum < nloops) {
+        goto again;
+    }
     fclose(file);
 
-   return 0;
+    return 0;
 }
 

+ 5 - 2
tests/emit_keys.c

@@ -14,7 +14,8 @@ typedef struct name_rec {
     UT_hash_handle hh;
 } name_rec;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     name_rec *name, *names=NULL;
     char linebuf[BUFLEN];
     FILE *file;
@@ -32,7 +33,9 @@ int main(int argc,char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (name_rec*)malloc(sizeof(name_rec));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->boy_name,linebuf,sizeof(name->boy_name));
         HASH_ADD_STR(names,boy_name,name);
         i++;

+ 35 - 21
tests/example.c

@@ -11,40 +11,45 @@ struct my_struct {
 
 struct my_struct *users = NULL;
 
-void add_user(int user_id, char *name) {
+void add_user(int user_id, char *name)
+{
     struct my_struct *s;
 
     HASH_FIND_INT(users, &user_id, s);  /* id already in the hash? */
     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 */
+        s = (struct my_struct*)malloc(sizeof(struct my_struct));
+        s->id = user_id;
+        HASH_ADD_INT( users, id, s );  /* id: name of key field */
     }
     strcpy(s->name, name);
 }
 
-struct my_struct *find_user(int user_id) {
+struct my_struct *find_user(int user_id)
+{
     struct my_struct *s;
 
     HASH_FIND_INT( users, &user_id, s );  /* s: output pointer */
     return s;
 }
 
-void delete_user(struct my_struct *user) {
+void delete_user(struct my_struct *user)
+{
     HASH_DEL( users, user);  /* user: pointer to deletee */
     free(user);
 }
 
-void delete_all() {
-  struct my_struct *current_user, *tmp;
+void delete_all()
+{
+    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_ITER(hh, users, current_user, tmp) {
+        HASH_DEL(users,current_user);  /* delete it (users advances to next) */
+        free(current_user);            /* free it */
+    }
 }
 
-void print_users() {
+void print_users()
+{
     struct my_struct *s;
 
     for(s=users; s != NULL; s=(struct my_struct*)(s->hh.next)) {
@@ -52,23 +57,28 @@ void print_users() {
     }
 }
 
-int name_sort(struct my_struct *a, struct my_struct *b) {
+int name_sort(struct my_struct *a, struct my_struct *b)
+{
     return strcmp(a->name,b->name);
 }
 
-int id_sort(struct my_struct *a, struct my_struct *b) {
+int id_sort(struct my_struct *a, struct my_struct *b)
+{
     return (a->id - b->id);
 }
 
-void sort_by_name() {
+void sort_by_name()
+{
     HASH_SORT(users, name_sort);
 }
 
-void sort_by_id() {
+void sort_by_id()
+{
     HASH_SORT(users, id_sort);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     char in[10];
     int id=1, running=1;
     struct my_struct *s;
@@ -93,7 +103,8 @@ int main(int argc, char *argv[]) {
                 break;
             case 2:
                 printf("id?\n");
-                gets(in); id = atoi(in);
+                gets(in);
+                id = atoi(in);
                 printf("name?\n");
                 add_user(id, gets(in));
                 break;
@@ -105,8 +116,11 @@ int main(int argc, char *argv[]) {
             case 4:
                 printf("id?\n");
                 s = find_user(atoi(gets(in)));
-                if (s) delete_user(s);
-                else printf("id unknown\n");
+                if (s) {
+                    delete_user(s);
+                } else {
+                    printf("id unknown\n");
+                }
                 break;
             case 5:
                 delete_all();

+ 519 - 443
tests/hashscan.c

@@ -45,15 +45,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifdef __FreeBSD__
 typedef struct {
-  void *start;
-  void *end;
+    void *start;
+    void *end;
 } vma_t;
 #else
 typedef struct {
-  off_t start;
-  off_t end;
-  char perms[4];   /* rwxp */
-  char device[5];  /* fd:01 or 00:00 */
+    off_t start;
+    off_t end;
+    char perms[4];   /* rwxp */
+    char device[5];  /* fd:01 or 00:00 */
 } vma_t;
 #endif
 
@@ -76,516 +76,592 @@ int getkeys=0;
 char *hash_fcns[] = {"???","JEN","BER","SFH","SAX","FNV","OAT","MUR"};
 
 /* given a peer key/len/hashv, reverse engineer its hash function */
-static int infer_hash_function(char *key, size_t keylen, uint32_t hashv) {
-  uint32_t obkt, ohashv, num_bkts=0x01000000; /* anything ok */
-  /* BER SAX FNV OAT JEN SFH */
-  HASH_JEN(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return JEN;
-  HASH_BER(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return BER;
-  HASH_SFH(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return SFH;
-  HASH_SAX(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return SAX;
-  HASH_FNV(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return FNV;
-  HASH_OAT(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return OAT;
-  HASH_MUR(key,keylen,num_bkts,ohashv,obkt); if (ohashv == hashv) return MUR;
-  obkt++; // this quiets an unused variable warning. yes, this is a ugly hack
-  return 0;
+static int infer_hash_function(char *key, size_t keylen, uint32_t hashv)
+{
+    uint32_t obkt, ohashv, num_bkts=0x01000000; /* anything ok */
+    /* BER SAX FNV OAT JEN SFH */
+    HASH_JEN(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return JEN;
+    }
+    HASH_BER(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return BER;
+    }
+    HASH_SFH(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return SFH;
+    }
+    HASH_SAX(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return SAX;
+    }
+    HASH_FNV(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return FNV;
+    }
+    HASH_OAT(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return OAT;
+    }
+    HASH_MUR(key,keylen,num_bkts,ohashv,obkt);
+    if (ohashv == hashv) {
+        return MUR;
+    }
+    obkt++; // this quiets an unused variable warning. yes, this is a ugly hack
+    return 0;
 }
 
 /* read peer's memory from addr for len bytes, store into our dst */
 #ifdef __FreeBSD__
-static int read_mem(void *dst, pid_t pid, void *start, size_t len) {
-  struct ptrace_io_desc io_desc;
-  int ret;
-
-  io_desc.piod_op = PIOD_READ_D;
-  io_desc.piod_offs = start;
-  io_desc.piod_addr = dst;
-  io_desc.piod_len = len;
-
-  ret = ptrace(PT_IO, pid, (void *) &io_desc, 0);
-
-  if (ret) {
-    vv("read_mem: ptrace failed: %s\n", strerror(errno));
-    return -1;
-  } else if (io_desc.piod_len != len) {
-    vv("read_mem: short read!\n");
-    return -1;
-  }
-
-  return 0;
+static int read_mem(void *dst, pid_t pid, void *start, size_t len)
+{
+    struct ptrace_io_desc io_desc;
+    int ret;
+
+    io_desc.piod_op = PIOD_READ_D;
+    io_desc.piod_offs = start;
+    io_desc.piod_addr = dst;
+    io_desc.piod_len = len;
+
+    ret = ptrace(PT_IO, pid, (void *) &io_desc, 0);
+
+    if (ret) {
+        vv("read_mem: ptrace failed: %s\n", strerror(errno));
+        return -1;
+    } else if (io_desc.piod_len != len) {
+        vv("read_mem: short read!\n");
+        return -1;
+    }
+
+    return 0;
 }
 #else
-static int read_mem(void *dst, int fd, off_t start, size_t len) {
-  int rc;
-  size_t bytes_read=0;
-  if (lseek(fd, start, SEEK_SET) == (off_t)-1) {
-    fprintf(stderr, "lseek failed: %s\n", strerror(errno));
-    return -1;
-  }
-  while ( len && ((rc=read(fd, (char*)dst+bytes_read, len)) > 0)) {
-    len -= rc;
-    bytes_read += rc;
-  }
-  if (rc==-1) vv("read_mem failed (%s)\n",strerror(errno));
-  if ((len != 0 && rc >= 0)) vv("INTERNAL ERROR\n");
-  return (rc == -1) ? -1 : 0;
+static int read_mem(void *dst, int fd, off_t start, size_t len)
+{
+    int rc;
+    size_t bytes_read=0;
+    if (lseek(fd, start, SEEK_SET) == (off_t)-1) {
+        fprintf(stderr, "lseek failed: %s\n", strerror(errno));
+        return -1;
+    }
+    while ( len && ((rc=read(fd, (char*)dst+bytes_read, len)) > 0)) {
+        len -= rc;
+        bytes_read += rc;
+    }
+    if (rc==-1) {
+        vv("read_mem failed (%s)\n",strerror(errno));
+    }
+    if ((len != 0 && rc >= 0)) {
+        vv("INTERNAL ERROR\n");
+    }
+    return (rc == -1) ? -1 : 0;
 }
 #endif
 
 /* later compensate for possible presence of bloom filter */
-static char *tbl_from_sig_addr(char *sig) {
-  return (sig - offsetof(UT_hash_table,signature));
+static char *tbl_from_sig_addr(char *sig)
+{
+    return (sig - offsetof(UT_hash_table,signature));
 }
 
 #define HS_BIT_TEST(v,i) (v[i/8] & (1U << (i%8)))
-static void found(int fd, char* peer_sig, pid_t pid) {
-  UT_hash_table *tbl=NULL;
-  UT_hash_bucket *bkts=NULL;
-  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,
-       *hash_fcn=NULL, sat[10];
-  unsigned char *bloombv=NULL;
-  static int fileno=0;
-  char keyfile[50];
-  unsigned char bloom_nbits=0;
-  int keyfd=-1, mode=S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
-      hash_fcn_hits[NUM_HASH_FUNCS], hash_fcn_winner;
-  unsigned max_chain=0;
-  uint32_t bloomsig;
-  double bloom_sat=0;
-  snprintf(sat,sizeof(sat),"         ");
-  for(i=0; i < NUM_HASH_FUNCS; i++) hash_fcn_hits[i]=0;
-
-  if (getkeys) {
-    snprintf(keyfile, sizeof(keyfile), "/tmp/%u-%u.key", (unsigned)pid,fileno++);
-    if ( (keyfd = open(keyfile, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) {
-      fprintf(stderr, "can't open %s: %s\n", keyfile, strerror(errno));
-      exit(-1);
-    }
-  }
-
-  vv("found signature at peer %p\n", peer_sig);
-  peer_tbl = tbl_from_sig_addr(peer_sig);
-  vvv("reading table at peer %p\n", peer_tbl);
-
-  if ( (tbl = (UT_hash_table*)malloc(sizeof(UT_hash_table))) == NULL) {
-    fprintf(stderr, "out of memory\n");
-    exit(-1);
-  }
-#ifdef __FreeBSD__
-  if (read_mem(tbl, pid, (void *)peer_tbl, sizeof(UT_hash_table)) != 0) {
-#else
-  if (read_mem(tbl, fd, (off_t)peer_tbl, sizeof(UT_hash_table)) != 0) {
-#endif
-    fprintf(stderr, "failed to read peer memory\n");
-    goto done;
-  }
-
-  /* got the table. how about the buckets */
-  peer_bkts = (char*)tbl->buckets;
-  vvv("reading buckets at peer %p\n", 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);
-  }
-#ifdef __FreeBSD__
-  if (read_mem(bkts, pid, (void *)peer_bkts, sizeof(UT_hash_bucket)*tbl->num_buckets) != 0) {
-#else
-  if (read_mem(bkts, fd, (off_t)peer_bkts, sizeof(UT_hash_bucket)*tbl->num_buckets) != 0) {
-#endif
-    fprintf(stderr, "failed to read peer memory\n");
-    goto done;
-  }
-
-  vvv("scanning %u peer buckets\n", tbl->num_buckets);
-  for(i=0; i < tbl->num_buckets; i++) {
-    vvv("bucket %u has %u items\n",  (unsigned)i, (unsigned)(bkts[i].count));
-    if (bkts[i].count > max_chain) max_chain = bkts[i].count;
-    if (bkts[i].expand_mult) vvv("  bucket %u has expand_mult %u\n",  (unsigned)i, (unsigned)(bkts[i].expand_mult));
-
-    vvv("scanning bucket %u chain:\n",  (unsigned)i);
-    peer_hh = (char*)bkts[i].hh_head;
-    while(peer_hh) {
+static void found(int fd, char* peer_sig, pid_t pid)
+{
+    UT_hash_table *tbl=NULL;
+    UT_hash_bucket *bkts=NULL;
+    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,
+                                                          *hash_fcn=NULL, sat[10];
+    unsigned char *bloombv=NULL;
+    static int fileno=0;
+    char keyfile[50];
+    unsigned char bloom_nbits=0;
+    int keyfd=-1, mode=S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
+        hash_fcn_hits[NUM_HASH_FUNCS], hash_fcn_winner;
+    unsigned max_chain=0;
+    uint32_t bloomsig;
+    double bloom_sat=0;
+    snprintf(sat,sizeof(sat),"         ");
+    for(i=0; i < NUM_HASH_FUNCS; i++) {
+        hash_fcn_hits[i]=0;
+    }
+
+    if (getkeys) {
+        snprintf(keyfile, sizeof(keyfile), "/tmp/%u-%u.key", (unsigned)pid,fileno++);
+        if ( (keyfd = open(keyfile, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) {
+            fprintf(stderr, "can't open %s: %s\n", keyfile, strerror(errno));
+            exit(-1);
+        }
+    }
+
+    vv("found signature at peer %p\n", peer_sig);
+    peer_tbl = tbl_from_sig_addr(peer_sig);
+    vvv("reading table at peer %p\n", peer_tbl);
+
+    if ( (tbl = (UT_hash_table*)malloc(sizeof(UT_hash_table))) == NULL) {
+        fprintf(stderr, "out of memory\n");
+        exit(-1);
+    }
 #ifdef __FreeBSD__
-      if (read_mem(&hh, pid, (void *)peer_hh, sizeof(hh)) != 0) {
+    if (read_mem(tbl, pid, (void *)peer_tbl, sizeof(UT_hash_table)) != 0) {
 #else
-      if (read_mem(&hh, fd, (off_t)peer_hh, sizeof(hh)) != 0) {
+    if (read_mem(tbl, fd, (off_t)peer_tbl, sizeof(UT_hash_table)) != 0) {
 #endif
         fprintf(stderr, "failed to read peer memory\n");
         goto done;
-      }
-      if ((char*)hh.tbl != peer_tbl) goto done;
-      peer_hh = (char*)hh.hh_next;
-      peer_key = (char*)(hh.key);
-      /* malloc space to read the key, and read it */
-      if ( (key = (char*)malloc(sizeof(hh.keylen))) == NULL) {
+    }
+
+    /* got the table. how about the buckets */
+    peer_bkts = (char*)tbl->buckets;
+    vvv("reading buckets at peer %p\n", 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);
-      }
+    }
 #ifdef __FreeBSD__
-      if (read_mem(key, pid, (void*)peer_key, hh.keylen) != 0) {
+    if (read_mem(bkts, pid, (void *)peer_bkts, sizeof(UT_hash_bucket)*tbl->num_buckets) != 0) {
 #else
-      if (read_mem(key, fd, (off_t)peer_key, hh.keylen) != 0) {
+    if (read_mem(bkts, fd, (off_t)peer_bkts, sizeof(UT_hash_bucket)*tbl->num_buckets) != 0) {
 #endif
         fprintf(stderr, "failed to read peer memory\n");
         goto done;
-      }
-      hash_fcn_hits[infer_hash_function(key,hh.keylen,hh.hashv)]++;
-      /* write the key if requested */
-      if (getkeys) {
-        write(keyfd, &hh.keylen, sizeof(unsigned));
-        write(keyfd, key, hh.keylen);
-      }
-      free(key); key=NULL;
-    }
-  }
-
-  /* does it have a bloom filter?  */
-  peer_bloom_sig =   peer_tbl + offsetof(UT_hash_table, bloom_sig);
-  peer_bloombv_ptr = peer_tbl + offsetof(UT_hash_table, bloom_bv);
-  peer_bloom_nbits = peer_tbl + offsetof(UT_hash_table, bloom_nbits);
-  vvv("looking for bloom signature at peer %p\n", peer_bloom_sig);
+    }
+
+    vvv("scanning %u peer buckets\n", tbl->num_buckets);
+    for(i=0; i < tbl->num_buckets; i++) {
+        vvv("bucket %u has %u items\n",  (unsigned)i, (unsigned)(bkts[i].count));
+        if (bkts[i].count > max_chain) {
+            max_chain = bkts[i].count;
+        }
+        if (bkts[i].expand_mult) {
+            vvv("  bucket %u has expand_mult %u\n",  (unsigned)i, (unsigned)(bkts[i].expand_mult));
+        }
+
+        vvv("scanning bucket %u chain:\n",  (unsigned)i);
+        peer_hh = (char*)bkts[i].hh_head;
+        while(peer_hh) {
 #ifdef __FreeBSD__
-  if ((read_mem(&bloomsig, pid, (void *)peer_bloom_sig, sizeof(uint32_t)) == 0)  &&
-      (bloomsig == HASH_BLOOM_SIGNATURE)) {
+            if (read_mem(&hh, pid, (void *)peer_hh, sizeof(hh)) != 0) {
 #else
-  if ((read_mem(&bloomsig, fd, (off_t)peer_bloom_sig, sizeof(uint32_t)) == 0)  &&
-      (bloomsig == HASH_BLOOM_SIGNATURE)) {
+            if (read_mem(&hh, fd, (off_t)peer_hh, sizeof(hh)) != 0) {
 #endif
-    vvv("bloom signature (%x) found\n",bloomsig);
-    /* bloom found. get at bv, nbits */
+                fprintf(stderr, "failed to read peer memory\n");
+                goto done;
+            }
+            if ((char*)hh.tbl != peer_tbl) {
+                goto done;
+            }
+            peer_hh = (char*)hh.hh_next;
+            peer_key = (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");
+                exit(-1);
+            }
 #ifdef __FreeBSD__
-    if (read_mem(&bloom_nbits, pid, (void *)peer_bloom_nbits, sizeof(char)) == 0) {
+            if (read_mem(key, pid, (void*)peer_key, hh.keylen) != 0) {
 #else
-    if (read_mem(&bloom_nbits, fd, (off_t)peer_bloom_nbits, sizeof(char)) == 0) {
+            if (read_mem(key, fd, (off_t)peer_key, hh.keylen) != 0) {
 #endif
-       /* scan bloom filter, calculate saturation */
-       bloom_bitlen = (1ULL << bloom_nbits);
-       bloom_len = (bloom_bitlen / 8) + ((bloom_bitlen % 8) ? 1 : 0);
-       vvv("bloom bitlen is %u, bloom_bytelen is %u\n", (unsigned)bloom_bitlen, (unsigned)bloom_len);
-       if ( (bloombv = (unsigned char*)malloc(bloom_len)) == NULL) {
-          fprintf(stderr, "out of memory\n");
-          exit(-1);
-       }
-       /* read the address of the bitvector in the peer, then read the bv itself */
+                fprintf(stderr, "failed to read peer memory\n");
+                goto done;
+            }
+            hash_fcn_hits[infer_hash_function(key,hh.keylen,hh.hashv)]++;
+            /* write the key if requested */
+            if (getkeys) {
+                write(keyfd, &hh.keylen, sizeof(unsigned));
+                write(keyfd, key, hh.keylen);
+            }
+            free(key);
+            key=NULL;
+        }
+    }
+
+    /* does it have a bloom filter?  */
+    peer_bloom_sig =   peer_tbl + offsetof(UT_hash_table, bloom_sig);
+    peer_bloombv_ptr = peer_tbl + offsetof(UT_hash_table, bloom_bv);
+    peer_bloom_nbits = peer_tbl + offsetof(UT_hash_table, bloom_nbits);
+    vvv("looking for bloom signature at peer %p\n", peer_bloom_sig);
 #ifdef __FreeBSD__
-       if ((read_mem(&peer_bloombv, pid, (void *)peer_bloombv_ptr, sizeof(void*)) == 0) &&
-          (read_mem(bloombv, pid, (void *)peer_bloombv, bloom_len) == 0)) {
+    if ((read_mem(&bloomsig, pid, (void *)peer_bloom_sig, sizeof(uint32_t)) == 0)  &&
+            (bloomsig == HASH_BLOOM_SIGNATURE)) {
 #else
-       if ((read_mem(&peer_bloombv, fd, (off_t)peer_bloombv_ptr, sizeof(void*)) == 0) &&
-          (read_mem(bloombv, fd, (off_t)peer_bloombv, bloom_len) == 0)) {
+    if ((read_mem(&bloomsig, fd, (off_t)peer_bloom_sig, sizeof(uint32_t)) == 0)  &&
+            (bloomsig == HASH_BLOOM_SIGNATURE)) {
 #endif
-          /* calculate saturation */
-          vvv("read peer bloom bitvector from %p (%u bytes)\n", peer_bloombv, (unsigned)bloom_len);
-          for(i=0; i < bloom_bitlen; i++) {
-              if (HS_BIT_TEST(bloombv,(unsigned)i)) {
-                /* vvv("bit %u set\n",(unsigned)i); */
-                bloom_on_bits++;
-              } else bloom_off_bits++;
-          }
-          vvv("there were %u on_bits among %u total bits\n", (unsigned)bloom_on_bits, (unsigned)bloom_bitlen);
-          bloom_sat = bloom_on_bits * 100.0 / bloom_bitlen;
-          snprintf(sat,sizeof(sat),"%2u %5.0f%%", bloom_nbits, bloom_sat);
-       }
-    }
-  }
-
-  /* choose apparent hash function */
-  hash_fcn_winner=0;
-  for(i=0;i<NUM_HASH_FUNCS;i++) {
-    if (hash_fcn_hits[i] > hash_fcn_hits[hash_fcn_winner]) hash_fcn_winner=i;
-  }
-  hash_fcn = hash_fcns[hash_fcn_winner];
+        vvv("bloom signature (%x) found\n",bloomsig);
+        /* bloom found. get at bv, nbits */
+#ifdef __FreeBSD__
+        if (read_mem(&bloom_nbits, pid, (void *)peer_bloom_nbits, sizeof(char)) == 0) {
+#else
+        if (read_mem(&bloom_nbits, fd, (off_t)peer_bloom_nbits, sizeof(char)) == 0) {
+#endif
+            /* scan bloom filter, calculate saturation */
+            bloom_bitlen = (1ULL << bloom_nbits);
+            bloom_len = (bloom_bitlen / 8) + ((bloom_bitlen % 8) ? 1 : 0);
+            vvv("bloom bitlen is %u, bloom_bytelen is %u\n", (unsigned)bloom_bitlen, (unsigned)bloom_len);
+            if ( (bloombv = (unsigned char*)malloc(bloom_len)) == NULL) {
+                fprintf(stderr, "out of memory\n");
+                exit(-1);
+            }
+            /* read the address of the bitvector in the peer, then read the bv itself */
+#ifdef __FreeBSD__
+            if ((read_mem(&peer_bloombv, pid, (void *)peer_bloombv_ptr, sizeof(void*)) == 0) &&
+                    (read_mem(bloombv, pid, (void *)peer_bloombv, bloom_len) == 0)) {
+#else
+            if ((read_mem(&peer_bloombv, fd, (off_t)peer_bloombv_ptr, sizeof(void*)) == 0) &&
+                    (read_mem(bloombv, fd, (off_t)peer_bloombv, bloom_len) == 0)) {
+#endif
+                /* calculate saturation */
+                vvv("read peer bloom bitvector from %p (%u bytes)\n", peer_bloombv, (unsigned)bloom_len);
+                for(i=0; i < bloom_bitlen; i++) {
+                    if (HS_BIT_TEST(bloombv,(unsigned)i)) {
+                        /* vvv("bit %u set\n",(unsigned)i); */
+                        bloom_on_bits++;
+                    } else {
+                        bloom_off_bits++;
+                    }
+                }
+                vvv("there were %u on_bits among %u total bits\n", (unsigned)bloom_on_bits, (unsigned)bloom_bitlen);
+                bloom_sat = bloom_on_bits * 100.0 / bloom_bitlen;
+                snprintf(sat,sizeof(sat),"%2u %5.0f%%", bloom_nbits, bloom_sat);
+            }
+        }
+    }
 
-/*
-Address            items    ideal  buckets mxch/<10 fl bloom/sat fcn keys saved to
------------------- -------- ----- -------- -------- -- --------- --- -------------
-0x0123456789abcdef 10000000  98%  32000000 10  100% ok           BER /tmp/9110-0.key
-0x0123456789abcdef 10000000 100%  32000000  9   90% NX 27/0.010% BER /tmp/9110-1.key
-*/
-  printf("Address            ideal    items  buckets mc fl bloom/sat fcn keys saved to\n");
-  printf("------------------ ----- -------- -------- -- -- --------- --- -------------\n");
-  printf("%-18p %4.0f%% %8u %8u %2u %s %s %s %s\n",
-    (void*)peer_tbl,
-    (tbl->num_items - tbl->nonideal_items) * 100.0 / tbl->num_items,
-    tbl->num_items,
-    tbl->num_buckets,
-    max_chain,
-    tbl->noexpand ? "NX" : "ok",
-    sat,
-    hash_fcn,
-    (getkeys ? keyfile : ""));
+    /* choose apparent hash function */
+    hash_fcn_winner=0;
+    for(i=0; i<NUM_HASH_FUNCS; i++) {
+        if (hash_fcn_hits[i] > hash_fcn_hits[hash_fcn_winner]) {
+            hash_fcn_winner=i;
+        }
+    }
+    hash_fcn = hash_fcns[hash_fcn_winner];
+
+    /*
+    Address            items    ideal  buckets mxch/<10 fl bloom/sat fcn keys saved to
+    ------------------ -------- ----- -------- -------- -- --------- --- -------------
+    0x0123456789abcdef 10000000  98%  32000000 10  100% ok           BER /tmp/9110-0.key
+    0x0123456789abcdef 10000000 100%  32000000  9   90% NX 27/0.010% BER /tmp/9110-1.key
+    */
+    printf("Address            ideal    items  buckets mc fl bloom/sat fcn keys saved to\n");
+    printf("------------------ ----- -------- -------- -- -- --------- --- -------------\n");
+    printf("%-18p %4.0f%% %8u %8u %2u %s %s %s %s\n",
+           (void*)peer_tbl,
+           (tbl->num_items - tbl->nonideal_items) * 100.0 / tbl->num_items,
+           tbl->num_items,
+           tbl->num_buckets,
+           max_chain,
+           tbl->noexpand ? "NX" : "ok",
+           sat,
+           hash_fcn,
+           (getkeys ? keyfile : ""));
 
 #if 0
-  printf("read peer tbl:\n");
-  printf("num_buckets: %u\n", tbl->num_buckets);
-  printf("num_items: %u\n", tbl->num_items);
-  printf("nonideal_items: %u (%.2f%%)\n", tbl->nonideal_items,
-    tbl->nonideal_items*100.0/tbl->num_items);
-  printf("expand: %s\n", tbl->noexpand ? "inhibited": "normal");
-  if (getkeys) printf("keys written to %s\n", keyfile);
+    printf("read peer tbl:\n");
+    printf("num_buckets: %u\n", tbl->num_buckets);
+    printf("num_items: %u\n", tbl->num_items);
+    printf("nonideal_items: %u (%.2f%%)\n", tbl->nonideal_items,
+           tbl->nonideal_items*100.0/tbl->num_items);
+    printf("expand: %s\n", tbl->noexpand ? "inhibited": "normal");
+    if (getkeys) {
+        printf("keys written to %s\n", keyfile);
+    }
 #endif
 
- done:
-  if (bkts) free(bkts);
-  if (tbl) free(tbl);
-  if (key) free(key);
-  if (keyfd != -1) close(keyfd);
-  if (bloombv) free(bloombv);
+done:
+    if (bkts) {
+        free(bkts);
+    }
+    if (tbl) {
+        free(tbl);
+    }
+    if (key) {
+        free(key);
+    }
+    if (keyfd != -1) {
+        close(keyfd);
+    }
+    if (bloombv) {
+        free(bloombv);
+    }
 }
 
 
 #ifdef __FreeBSD__
-static void sigscan(pid_t pid, void *start, void *end, uint32_t sig) {
-  struct ptrace_io_desc io_desc;
-  int page_size = getpagesize();
-  char *buf;
-  char *pos;
-
-  /* make sure page_size is a multiple of the signature size, code below assumes this */
-  assert(page_size % sizeof(sig) == 0);
+static void sigscan(pid_t pid, void *start, void *end, uint32_t sig)
+{
+    struct ptrace_io_desc io_desc;
+    int page_size = getpagesize();
+    char *buf;
+    char *pos;
 
-  buf = malloc(page_size);
+    /* make sure page_size is a multiple of the signature size, code below assumes this */
+    assert(page_size % sizeof(sig) == 0);
 
-  if (buf == NULL) {
-	fprintf(stderr, "malloc failed in sigscan()\n");
-	return;
-  }
+    buf = malloc(page_size);
 
-  io_desc.piod_op = PIOD_READ_D;
-  io_desc.piod_offs = start;
-  io_desc.piod_addr = buf;
-  io_desc.piod_len = page_size;
-
-  /* read in one page after another and search sig */
-  while(!ptrace(PT_IO, pid, (void *) &io_desc, 0)) {
-    if (io_desc.piod_len != page_size) {
-      fprintf(stderr, "PT_IO returned less than page size in sigscan()\n");
-      return;
+    if (buf == NULL) {
+        fprintf(stderr, "malloc failed in sigscan()\n");
+        return;
     }
 
-    /* iterate over the the page using the signature size and look for the sig */
-    for (pos = buf; pos < (buf + page_size); pos += sizeof(sig)) {
-      if (*(uint32_t *) pos == sig) {
-        found(pid, (char *) io_desc.piod_offs + (pos - buf), pid);
-      }
+    io_desc.piod_op = PIOD_READ_D;
+    io_desc.piod_offs = start;
+    io_desc.piod_addr = buf;
+    io_desc.piod_len = page_size;
+
+    /* read in one page after another and search sig */
+    while(!ptrace(PT_IO, pid, (void *) &io_desc, 0)) {
+        if (io_desc.piod_len != page_size) {
+            fprintf(stderr, "PT_IO returned less than page size in sigscan()\n");
+            return;
+        }
+
+        /* iterate over the the page using the signature size and look for the sig */
+        for (pos = buf; pos < (buf + page_size); pos += sizeof(sig)) {
+            if (*(uint32_t *) pos == sig) {
+                found(pid, (char *) io_desc.piod_offs + (pos - buf), pid);
+            }
+        }
+
+        /*
+         * 'end' is inclusive (the address of the last valid byte), so if the current offset
+         * plus a page is beyond 'end', we're already done. since all vm map entries consist
+         * of entire pages and 'end' is inclusive, current offset plus one page should point
+         * exactly one byte beyond 'end'. this is assert()ed below to be on the safe side.
+         */
+        if (io_desc.piod_offs + page_size > end) {
+            assert(io_desc.piod_offs + page_size == (end + 1));
+            break;
+        }
+
+        /* advance to the next page */
+        io_desc.piod_offs += page_size;
     }
-
-    /*
-     * 'end' is inclusive (the address of the last valid byte), so if the current offset
-     * plus a page is beyond 'end', we're already done. since all vm map entries consist
-     * of entire pages and 'end' is inclusive, current offset plus one page should point
-     * exactly one byte beyond 'end'. this is assert()ed below to be on the safe side.
-     */
-    if (io_desc.piod_offs + page_size > end) {
-      assert(io_desc.piod_offs + page_size == (end + 1));
-      break;
-    }
-
-    /* advance to the next page */
-    io_desc.piod_offs += page_size;
-  }
 }
 #else
-static void sigscan(int fd, off_t start, off_t end, uint32_t sig, pid_t pid) {
-  int rlen;
-  uint32_t u;
-  off_t at=0;
-
-  if (lseek(fd, start, SEEK_SET) == (off_t)-1) {
-    fprintf(stderr, "lseek failed: %s\n", strerror(errno));
-    return;
-  }
-
-  while ( (rlen = read(fd,&u,sizeof(u))) == sizeof(u)) {
-     if (!memcmp(&u,&sig,sizeof(u))) found(fd, (char*)(start+at),pid);
-     at += sizeof(u);
-     if ((off_t)(at + sizeof(u)) > end-start) break;
-  }
-
-  if (rlen == -1) {
-    //fprintf(stderr,"read failed: %s\n", strerror(errno));
-    //exit(-1);
-  }
+static void sigscan(int fd, off_t start, off_t end, uint32_t sig, pid_t pid)
+{
+    int rlen;
+    uint32_t u;
+    off_t at=0;
+
+    if (lseek(fd, start, SEEK_SET) == (off_t)-1) {
+        fprintf(stderr, "lseek failed: %s\n", strerror(errno));
+        return;
+    }
+
+    while ( (rlen = read(fd,&u,sizeof(u))) == sizeof(u)) {
+        if (!memcmp(&u,&sig,sizeof(u))) {
+            found(fd, (char*)(start+at),pid);
+        }
+        at += sizeof(u);
+        if ((off_t)(at + sizeof(u)) > end-start) {
+            break;
+        }
+    }
+
+    if (rlen == -1) {
+        //fprintf(stderr,"read failed: %s\n", strerror(errno));
+        //exit(-1);
+    }
 }
 #endif
 
 
 #ifdef __FreeBSD__
-static int scan(pid_t pid) {
-  vma_t *vmas=NULL, vma;
-  unsigned i, num_vmas = 0;
-  int ret;
-  struct ptrace_vm_entry vm_entry;
-  char path[MAXPATHLEN];
-
-  vv("attaching to peer\n");
-  if (ptrace(PT_ATTACH,pid,NULL,0) == -1) {
-    fprintf(stderr,"failed to attach to %u: %s\n", (unsigned)pid, strerror(errno));
-    exit(EXIT_FAILURE);
-  }
-  vv("waiting for peer to suspend temporarily\n");
-  if (waitpid(pid,NULL,0) != pid) {
-    fprintf(stderr,"failed to wait for pid %u: %s\n",(unsigned)pid, strerror(errno));
-    goto die;
-  }
-
-  /* read memory map using ptrace */
-  vv("listing peer virtual memory areas\n");
-  vm_entry.pve_entry = 0;
-  vm_entry.pve_path = path; /* not used but required to make vm_entry.pve_pathlen work */
-  while(1) {
-    /* set pve_pathlen every turn, it gets overwritten by ptrace */
-    vm_entry.pve_pathlen = MAXPATHLEN;
-    errno = 0;
-
-    ret = ptrace(PT_VM_ENTRY, pid, (void *) &vm_entry, 0);
+static int scan(pid_t pid)
+{
+    vma_t *vmas=NULL, vma;
+    unsigned i, num_vmas = 0;
+    int ret;
+    struct ptrace_vm_entry vm_entry;
+    char path[MAXPATHLEN];
+
+    vv("attaching to peer\n");
+    if (ptrace(PT_ATTACH,pid,NULL,0) == -1) {
+        fprintf(stderr,"failed to attach to %u: %s\n", (unsigned)pid, strerror(errno));
+        exit(EXIT_FAILURE);
+    }
+    vv("waiting for peer to suspend temporarily\n");
+    if (waitpid(pid,NULL,0) != pid) {
+        fprintf(stderr,"failed to wait for pid %u: %s\n",(unsigned)pid, strerror(errno));
+        goto die;
+    }
 
-    if (ret) {
-      if (errno == ENOENT) {
-        /* we've reached the last entry */
-	break;
-      }
-      fprintf(stderr, "fetching vm map entry failed: %s (%i)\n", strerror(errno), errno);
-      goto die;
+    /* read memory map using ptrace */
+    vv("listing peer virtual memory areas\n");
+    vm_entry.pve_entry = 0;
+    vm_entry.pve_path = path; /* not used but required to make vm_entry.pve_pathlen work */
+    while(1) {
+        /* set pve_pathlen every turn, it gets overwritten by ptrace */
+        vm_entry.pve_pathlen = MAXPATHLEN;
+        errno = 0;
+
+        ret = ptrace(PT_VM_ENTRY, pid, (void *) &vm_entry, 0);
+
+        if (ret) {
+            if (errno == ENOENT) {
+                /* we've reached the last entry */
+                break;
+            }
+            fprintf(stderr, "fetching vm map entry failed: %s (%i)\n", strerror(errno), errno);
+            goto die;
+        }
+
+        vvv("vmmap entry: start: %p, end: %p", (void *) vm_entry.pve_start, (void *) vm_entry.pve_end);
+
+        /* skip unreadable or vnode-backed entries */
+        if (!(vm_entry.pve_prot & VM_PROT_READ) || vm_entry.pve_pathlen > 0) {
+            vvv(" -> skipped (not readable or vnode-backed)\n");
+            vm_entry.pve_path[0] = 0;
+            continue;
+        }
+
+        /* useful entry, add to list */
+        vvv(" -> will be scanned\n");
+        vma.start = (void *)vm_entry.pve_start;
+        vma.end = (void *)vm_entry.pve_end;
+        vmas = (vma_t *) realloc(vmas, (num_vmas + 1) * sizeof(vma_t));
+        if (vmas == NULL) {
+            exit(-1);
+        }
+        vmas[num_vmas++] = vma;
     }
 
-    vvv("vmmap entry: start: %p, end: %p", (void *) vm_entry.pve_start, (void *) vm_entry.pve_end);
+    vv("peer has %u virtual memory areas\n", num_vmas);
 
-    /* skip unreadable or vnode-backed entries */
-    if (!(vm_entry.pve_prot & VM_PROT_READ) || vm_entry.pve_pathlen > 0) {
-      vvv(" -> skipped (not readable or vnode-backed)\n");
-      vm_entry.pve_path[0] = 0;
-      continue;
+    /* look for the hash signature */
+    vv("scanning peer memory for hash table signatures\n");
+    for(i=0; i<num_vmas; i++) {
+        vma = vmas[i];
+        sigscan(pid, vma.start, vma.end, sig);
     }
 
-    /* useful entry, add to list */
-    vvv(" -> will be scanned\n");
-    vma.start = (void *)vm_entry.pve_start;
-    vma.end = (void *)vm_entry.pve_end;
-    vmas = (vma_t *) realloc(vmas, (num_vmas + 1) * sizeof(vma_t));
-    if (vmas == NULL) exit(-1);
-    vmas[num_vmas++] = vma;
-  }
+die:
+    vv("detaching and resuming peer\n");
+    if (ptrace(PT_DETACH, pid, NULL, 0) == -1) {
+        fprintf(stderr,"failed to detach from %u: %s\n", (unsigned)pid, strerror(errno));
+    }
+    return 0;
+}
+# else
+static int scan(pid_t pid)
+{
+    FILE *mapf;
+    char mapfile[30], memfile[30], line[100];
+    vma_t *vmas=NULL, vma;
+    unsigned i, num_vmas = 0;
+    int memfd;
+    void *pstart, *pend, *unused;
+
+    /* attach to the target process and wait for it to suspend */
+    vv("attaching to peer\n");
+    if (ptrace(PTRACE_ATTACH,pid,NULL,NULL) == -1) {
+        fprintf(stderr,"failed to attach to %u: %s\n", (unsigned)pid, strerror(errno));
+        exit(-1);
+    }
+    vv("waiting for peer to suspend temporarily\n");
+    if (waitpid(pid,NULL,0) != pid) {
+        fprintf(stderr,"failed to wait for pid %u: %s\n",(unsigned)pid, strerror(errno));
+        goto die;
+    }
 
-  vv("peer has %u virtual memory areas\n", num_vmas);
+    /* get ready to open its memory map. this gives us its valid memory areas */
+    snprintf(mapfile,sizeof(mapfile),"/proc/%u/maps",(unsigned)pid);
+    snprintf(memfile,sizeof(memfile),"/proc/%u/mem", (unsigned)pid);
+    vv("opening peer memory map [%s]\n", mapfile);
+    if ( (mapf = fopen(mapfile,"r")) == NULL) {
+        fprintf(stderr,"failed to open %s: %s\n", mapfile, strerror(errno));
+        goto die;
+    }
+    vv("listing peer virtual memory areas\n");
+    while(fgets(line,sizeof(line),mapf)) {
+        if (sscanf(line, "%p-%p %4c %p %5c", &pstart, &pend, vma.perms,
+                   &unused, vma.device) == 5) {
+            vma.start = (off_t)pstart;
+            vma.end = (off_t)pend;
+            if (vma.perms[0] != 'r') {
+                continue;    /* only readable vma's */
+            }
+            if (memcmp(vma.device,"fd",2)==0) {
+                continue;    /* skip mapped files */
+            }
+            vmas = (vma_t*)realloc(vmas, (num_vmas+1) * sizeof(vma_t));
+            if (vmas == NULL) {
+                exit(-1);
+            }
+            vmas[num_vmas++] = vma;
+        }
+    }
+    vv("peer has %u virtual memory areas\n",num_vmas);
+    fclose(mapf);
+
+    /* ok, open up its memory and start looking around in there */
+    vv("opening peer memory\n");
+    if ( (memfd=open(memfile,O_RDONLY)) == -1) {
+        fprintf(stderr,"failed to open %s: %s\n", memfile, strerror(errno));
+        goto die;
+    }
+    /* look for the hash signature */
+    vv("scanning peer memory for hash table signatures\n");
+    for(i=0; i<num_vmas; i++) {
+        vma = vmas[i];
+        pstart = (void*)vma.start;
+        pend = (void*)vma.end;
+        /*fprintf(stderr,"scanning %p-%p %.4s %.5s\n", pstart, pend,
+                  vma.perms, vma.device);*/
+        sigscan(memfd, vma.start, vma.end, sig, pid);
+    }
 
-  /* look for the hash signature */
-  vv("scanning peer memory for hash table signatures\n");
-  for(i=0;i<num_vmas;i++) {
-    vma = vmas[i];
-    sigscan(pid, vma.start, vma.end, sig);
-  }
+    /* done. close memory and detach. this resumes the target process */
+    close(memfd);
 
 die:
-  vv("detaching and resuming peer\n");
-  if (ptrace(PT_DETACH, pid, NULL, 0) == -1) {
-    fprintf(stderr,"failed to detach from %u: %s\n", (unsigned)pid, strerror(errno));
-  }
-  return 0;
-}
-# else
-static int scan(pid_t pid) {
-  FILE *mapf;
-  char mapfile[30], memfile[30], line[100];
-  vma_t *vmas=NULL, vma;
-  unsigned i, num_vmas = 0;
-  int memfd;
-  void *pstart, *pend, *unused;
-
-  /* attach to the target process and wait for it to suspend */
-  vv("attaching to peer\n");
-  if (ptrace(PTRACE_ATTACH,pid,NULL,NULL) == -1) {
-    fprintf(stderr,"failed to attach to %u: %s\n", (unsigned)pid, strerror(errno));
-    exit(-1);
-  }
-  vv("waiting for peer to suspend temporarily\n");
-  if (waitpid(pid,NULL,0) != pid) {
-    fprintf(stderr,"failed to wait for pid %u: %s\n",(unsigned)pid, strerror(errno));
-    goto die;
-  }
-
-  /* get ready to open its memory map. this gives us its valid memory areas */
-  snprintf(mapfile,sizeof(mapfile),"/proc/%u/maps",(unsigned)pid);
-  snprintf(memfile,sizeof(memfile),"/proc/%u/mem", (unsigned)pid);
-  vv("opening peer memory map [%s]\n", mapfile);
-  if ( (mapf = fopen(mapfile,"r")) == NULL) {
-    fprintf(stderr,"failed to open %s: %s\n", mapfile, strerror(errno));
-    goto die;
-  }
-  vv("listing peer virtual memory areas\n");
-  while(fgets(line,sizeof(line),mapf)) {
-    if (sscanf(line, "%p-%p %4c %p %5c", &pstart, &pend, vma.perms,
-         &unused, vma.device) == 5) {
-      vma.start = (off_t)pstart;
-      vma.end = (off_t)pend;
-      if (vma.perms[0] != 'r') continue;          /* only readable vma's */
-      if (memcmp(vma.device,"fd",2)==0) continue; /* skip mapped files */
-      vmas = (vma_t*)realloc(vmas, (num_vmas+1) * sizeof(vma_t));
-      if (vmas == NULL) exit(-1);
-      vmas[num_vmas++] = vma;
-    }
-  }
-  vv("peer has %u virtual memory areas\n",num_vmas);
-  fclose(mapf);
-
-  /* ok, open up its memory and start looking around in there */
-  vv("opening peer memory\n");
-  if ( (memfd=open(memfile,O_RDONLY)) == -1) {
-    fprintf(stderr,"failed to open %s: %s\n", memfile, strerror(errno));
-    goto die;
-  }
-  /* look for the hash signature */
-  vv("scanning peer memory for hash table signatures\n");
-  for(i=0;i<num_vmas;i++) {
-    vma = vmas[i];
-    pstart = (void*)vma.start;
-    pend = (void*)vma.end;
-    /*fprintf(stderr,"scanning %p-%p %.4s %.5s\n", pstart, pend,
-              vma.perms, vma.device);*/
-    sigscan(memfd, vma.start, vma.end, sig, pid);
-  }
-
-  /* done. close memory and detach. this resumes the target process */
-  close(memfd);
-
- die:
-  vv("detaching and resuming peer\n");
-  if (ptrace(PTRACE_DETACH, pid, NULL, NULL) == -1) {
-    fprintf(stderr,"failed to detach from %u: %s\n", (unsigned)pid, strerror(errno));
-  }
-  return 0;
+    vv("detaching and resuming peer\n");
+    if (ptrace(PTRACE_DETACH, pid, NULL, NULL) == -1) {
+        fprintf(stderr,"failed to detach from %u: %s\n", (unsigned)pid, strerror(errno));
+    }
+    return 0;
 }
 #endif
 
 
-static void usage(const char *prog) {
-  fprintf(stderr,"usage: %s [-v] [-k] <pid>\n", prog);
-  exit(-1);
+static void usage(const char *prog)
+{
+    fprintf(stderr,"usage: %s [-v] [-k] <pid>\n", prog);
+    exit(-1);
 }
 
-int main(int argc, char *argv[]) {
-  pid_t pid;
-  int opt;
-
-  while ( (opt = getopt(argc, argv, "kv")) != -1) {
-    switch (opt) {
-      case 'v':
-        verbose++;
-        break;
-      case 'k':
-        getkeys++;
-        break;
-      default:
-        usage(argv[0]);
-        break;
+int main(int argc, char *argv[])
+{
+    pid_t pid;
+    int opt;
+
+    while ( (opt = getopt(argc, argv, "kv")) != -1) {
+        switch (opt) {
+            case 'v':
+                verbose++;
+                break;
+            case 'k':
+                getkeys++;
+                break;
+            default:
+                usage(argv[0]);
+                break;
+        }
     }
-  }
 
-  if (optind < argc) pid=atoi(argv[optind++]);
-  else usage(argv[0]);
+    if (optind < argc) {
+        pid=atoi(argv[optind++]);
+    } else {
+        usage(argv[0]);
+    }
 
-  return scan(pid);
+    return scan(pid);
 }

+ 134 - 99
tests/keystat.c

@@ -12,9 +12,10 @@
 #define uthash_noexpand_fyi(t) die()
 #define UNALIGNED_KEYS 0
 
-static void die() {
-  fprintf(stderr,"expansion inhibited\n");
-  exit(-1);
+static void die()
+{
+    fprintf(stderr,"expansion inhibited\n");
+    exit(-1);
 }
 
 /* Windows doesn't have gettimeofday. While Cygwin and some
@@ -22,16 +23,17 @@ static void die() {
  * gives much more accurate elapsed times under Windows. */
 #if (( defined __CYGWIN__ ) || ( defined __MINGW32__ ))
 #include <windows.h>
-static void win_gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
-  LARGE_INTEGER q;
-  static long long freq;
-  static long long cyg_timer;
-  QueryPerformanceFrequency(&q);
-  freq = q.QuadPart;
-  QueryPerformanceCounter(&q);
-  cyg_timer = q.QuadPart;
-  p->tv_sec = (long)(cyg_timer / freq);
-  p->tv_usec = (long)(((cyg_timer % freq) * 1000000) / freq);
+static void win_gettimeofday(struct timeval* p, void* tz /* IGNORED */)
+{
+    LARGE_INTEGER q;
+    static long long freq;
+    static long long cyg_timer;
+    QueryPerformanceFrequency(&q);
+    freq = q.QuadPart;
+    QueryPerformanceCounter(&q);
+    cyg_timer = q.QuadPart;
+    p->tv_sec = (long)(cyg_timer / freq);
+    p->tv_usec = (long)(((cyg_timer % freq) * 1000000) / freq);
 }
 #define gettimeofday win_gettimeofday
 #define MODE (O_RDONLY|O_BINARY)
@@ -63,28 +65,37 @@ typedef struct stat_key {
 #define CHAIN_20  3
 #define CHAIN_100 4
 #define CHAIN_MAX 5
-static void hash_chain_len_histogram(const UT_hash_table *tbl) {
-  unsigned i, bkt_hist[CHAIN_MAX+1];
-  double pct = 100.0/(double)tbl->num_buckets;
-  memset(bkt_hist,0,sizeof(bkt_hist));
-  for(i=0; i < tbl->num_buckets; i++) {
-      unsigned count = tbl->buckets[i].count;
-      if (count == 0U) bkt_hist[CHAIN_0]++;
-      else if (count < 5U) bkt_hist[CHAIN_5]++;
-      else if (count < 10U) bkt_hist[CHAIN_10]++;
-      else if (count < 20U) bkt_hist[CHAIN_20]++;
-      else if (count < 100U) bkt_hist[CHAIN_100]++;
-      else bkt_hist[CHAIN_MAX]++;
-  }
-  fprintf(stderr, "Buckets with     0 items: %.1f%%\n", (double)bkt_hist[CHAIN_0 ]*pct);
-  fprintf(stderr, "Buckets with <   5 items: %.1f%%\n", (double)bkt_hist[CHAIN_5 ]*pct);
-  fprintf(stderr, "Buckets with <  10 items: %.1f%%\n", (double)bkt_hist[CHAIN_10]*pct);
-  fprintf(stderr, "Buckets with <  20 items: %.1f%%\n", (double)bkt_hist[CHAIN_20]*pct);
-  fprintf(stderr, "Buckets with < 100 items: %.1f%%\n", (double)bkt_hist[CHAIN_100]*pct);
-  fprintf(stderr, "Buckets with > 100 items: %.1f%%\n", (double)bkt_hist[CHAIN_MAX]*pct);
+static void hash_chain_len_histogram(const UT_hash_table *tbl)
+{
+    unsigned i, bkt_hist[CHAIN_MAX+1];
+    double pct = 100.0/(double)tbl->num_buckets;
+    memset(bkt_hist,0,sizeof(bkt_hist));
+    for(i=0; i < tbl->num_buckets; i++) {
+        unsigned count = tbl->buckets[i].count;
+        if (count == 0U) {
+            bkt_hist[CHAIN_0]++;
+        } else if (count < 5U) {
+            bkt_hist[CHAIN_5]++;
+        } else if (count < 10U) {
+            bkt_hist[CHAIN_10]++;
+        } else if (count < 20U) {
+            bkt_hist[CHAIN_20]++;
+        } else if (count < 100U) {
+            bkt_hist[CHAIN_100]++;
+        } else {
+            bkt_hist[CHAIN_MAX]++;
+        }
+    }
+    fprintf(stderr, "Buckets with     0 items: %.1f%%\n", (double)bkt_hist[CHAIN_0 ]*pct);
+    fprintf(stderr, "Buckets with <   5 items: %.1f%%\n", (double)bkt_hist[CHAIN_5 ]*pct);
+    fprintf(stderr, "Buckets with <  10 items: %.1f%%\n", (double)bkt_hist[CHAIN_10]*pct);
+    fprintf(stderr, "Buckets with <  20 items: %.1f%%\n", (double)bkt_hist[CHAIN_20]*pct);
+    fprintf(stderr, "Buckets with < 100 items: %.1f%%\n", (double)bkt_hist[CHAIN_100]*pct);
+    fprintf(stderr, "Buckets with > 100 items: %.1f%%\n", (double)bkt_hist[CHAIN_MAX]*pct);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int dups=0, rc, fd, done=0, err=0, want, i, padding=0, v=1, percent=100;
     unsigned keylen, max_keylen=0, verbose=0;
     const char *filename = "/dev/stdin";
@@ -92,9 +103,17 @@ int main(int argc, char *argv[]) {
     stat_key *keyt, *keytmp, *keys=NULL, *keys2=NULL;
     struct timeval start_tm, end_tm, elapsed_tm, elapsed_tm2, elapsed_tm3;
 
-    if ((argc >= 3) && (strcmp(argv[1],"-p") == 0)) {percent = atoi(argv[2]); v = 3;}
-    if ((argc >= v) && (strcmp(argv[v],"-v") == 0)) {verbose=1; v++;}
-    if (argc >= v) filename=argv[v];
+    if ((argc >= 3) && (strcmp(argv[1],"-p") == 0)) {
+        percent = atoi(argv[2]);
+        v = 3;
+    }
+    if ((argc >= v) && (strcmp(argv[v],"-v") == 0)) {
+        verbose=1;
+        v++;
+    }
+    if (argc >= v) {
+        filename=argv[v];
+    }
     fd=open(filename,MODE);
 
     if ( fd == -1 ) {
@@ -104,79 +123,93 @@ int main(int argc, char *argv[]) {
 
     for(i=0; done==0; i++) {
 
-          want = sizeof(int);
-          dst = (char*)&keylen;
-          readmore1:
-          rc = read(fd,dst,want);
-          if (rc != want) {
-              if (rc == 0) done=1;
-              else if (rc == -1) {
+        want = sizeof(int);
+        dst = (char*)&keylen;
+readmore1:
+        rc = read(fd,dst,want);
+        if (rc != want) {
+            if (rc == 0) {
+                done=1;
+            } else if (rc == -1) {
                 fprintf(stderr,"read failed: %s\n", strerror(errno));
                 err=1;
-              }
-              else if (rc > 0) { want -= rc; dst += rc; goto readmore1; }
-          }
+            } else if (rc > 0) {
+                want -= rc;
+                dst += rc;
+                goto readmore1;
+            }
+        }
 
-          if (done || err) break;
-          if (keylen > max_keylen) max_keylen=keylen;
+        if (done || err) {
+            break;
+        }
+        if (keylen > max_keylen) {
+            max_keylen=keylen;
+        }
 
-          keyt = (stat_key*)malloc(sizeof(stat_key));
-          if (keyt == NULL) {
-              fprintf(stderr,"out of memory\n");
-              exit(-1);
-          }
+        keyt = (stat_key*)malloc(sizeof(stat_key));
+        if (keyt == NULL) {
+            fprintf(stderr,"out of memory\n");
+            exit(-1);
+        }
 
-          /* read key */
+        /* read key */
 #ifdef UNALIGNED_KEYS
-          padding = i%8;
+        padding = i%8;
 #endif
-          keyt->key = (char*)malloc(padding+keylen);
-          if (keyt->key == NULL) {
-              fprintf(stderr,"out of memory\n");
-              exit(-1);
-          }
-          keyt->key += padding; /* forcibly alter the alignment of key */
-          keyt->len = keylen;
-
-          want = keylen;
-          dst = keyt->key;
-          readmore2:
-          rc = read(fd,dst,want);
-          if (rc != want) {
-              if (rc == -1) {
+        keyt->key = (char*)malloc(padding+keylen);
+        if (keyt->key == NULL) {
+            fprintf(stderr,"out of memory\n");
+            exit(-1);
+        }
+        keyt->key += padding; /* forcibly alter the alignment of key */
+        keyt->len = keylen;
+
+        want = keylen;
+        dst = keyt->key;
+readmore2:
+        rc = read(fd,dst,want);
+        if (rc != want) {
+            if (rc == -1) {
                 fprintf(stderr,"read failed: %s\n", strerror(errno));
                 err=1;
-              } else if (rc == 0) {
+            } else if (rc == 0) {
                 fprintf(stderr,"incomplete file\n");
                 err=1;
-              } else if (rc >= 0) { want -= rc; dst += rc; goto readmore2; }
-          }
-          if (err != 0) break;
-          /* if percent was set to something less than 100%, skip some keys*/
-          if (((rand()*1.0) / RAND_MAX) > ((percent*1.0)/100)) {
+            } else if (rc >= 0) {
+                want -= rc;
+                dst += rc;
+                goto readmore2;
+            }
+        }
+        if (err != 0) {
+            break;
+        }
+        /* if percent was set to something less than 100%, skip some keys*/
+        if (((rand()*1.0) / RAND_MAX) > ((percent*1.0)/100)) {
             free(keyt->key-padding);
             free(keyt);
             continue;
-          }
+        }
 
-          /* eliminate dups */
-          HASH_FIND(hh,keys,keyt->key,keylen,keytmp);
-          if (keytmp != NULL) {
-              dups++;
-              free(keyt->key - padding);
+        /* eliminate dups */
+        HASH_FIND(hh,keys,keyt->key,keylen,keytmp);
+        if (keytmp != NULL) {
+            dups++;
+            free(keyt->key - padding);
             free(keyt);
-          } else {
+        } else {
             HASH_ADD_KEYPTR(hh,keys,keyt->key,keylen,keyt);
-          }
+        }
     }
 
     if (verbose != 0) {
-      unsigned key_count = HASH_COUNT(keys);
-      fprintf(stderr,"max key length: %u\n", max_keylen);
-      fprintf(stderr,"number unique keys: %u\n", key_count);
-      fprintf(stderr,"keystats memory: %u\n",
-        (unsigned)((sizeof(stat_key)+max_keylen)*key_count));
-      hash_chain_len_histogram(keys->hh.tbl);
+        unsigned key_count = HASH_COUNT(keys);
+        fprintf(stderr,"max key length: %u\n", max_keylen);
+        fprintf(stderr,"number unique keys: %u\n", key_count);
+        fprintf(stderr,"keystats memory: %u\n",
+                (unsigned)((sizeof(stat_key)+max_keylen)*key_count));
+        hash_chain_len_histogram(keys->hh.tbl);
     }
 
     /* add all keys to a new hash, so we can measure add time w/o malloc */
@@ -191,7 +224,9 @@ int main(int argc, char *argv[]) {
     gettimeofday(&start_tm,NULL);
     for(keyt = keys; keyt != NULL; keyt=(stat_key*)keyt->hh.next) {
         HASH_FIND(hh2,keys2,keyt->key,keyt->len,keytmp);
-        if (keytmp == NULL) fprintf(stderr,"internal error, key not found\n");
+        if (keytmp == NULL) {
+            fprintf(stderr,"internal error, key not found\n");
+        }
     }
     gettimeofday(&end_tm,NULL);
     timersub(&end_tm, &start_tm, &elapsed_tm2);
@@ -207,15 +242,15 @@ int main(int argc, char *argv[]) {
 
     if (err == 0) {
         printf("%.3f,%u,%u,%d,%s,%ld,%ld,%ld\n",
-        1-(1.0*keys->hh.tbl->nonideal_items/keys->hh.tbl->num_items),
-        keys->hh.tbl->num_items,
-        keys->hh.tbl->num_buckets,
-        dups,
-        (keys->hh.tbl->noexpand != 0U) ? "nx" : "ok",
-        (elapsed_tm.tv_sec * 1000000) + elapsed_tm.tv_usec,
-        (elapsed_tm2.tv_sec * 1000000) + elapsed_tm2.tv_usec,
-        (elapsed_tm3.tv_sec * 1000000) + elapsed_tm3.tv_usec );
+               1-(1.0*keys->hh.tbl->nonideal_items/keys->hh.tbl->num_items),
+               keys->hh.tbl->num_items,
+               keys->hh.tbl->num_buckets,
+               dups,
+               (keys->hh.tbl->noexpand != 0U) ? "nx" : "ok",
+               (elapsed_tm.tv_sec * 1000000) + elapsed_tm.tv_usec,
+               (elapsed_tm2.tv_sec * 1000000) + elapsed_tm2.tv_usec,
+               (elapsed_tm3.tv_sec * 1000000) + elapsed_tm3.tv_usec );
     }
-  return 0;
+    return 0;
 }
 

+ 6 - 3
tests/sleep_test.c

@@ -9,13 +9,16 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10000;i++) {
-        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL) exit(-1);
+    for(i=0; i<10000; i++) {
+        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);

+ 7 - 4
tests/test1.c

@@ -8,14 +8,17 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -24,5 +27,5 @@ int main(int argc,char *argv[]) {
     for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {
         printf("user %d, cookie %d\n", user->id, user->cookie);
     }
-   return 0;
+    return 0;
 }

+ 10 - 5
tests/test10.c

@@ -9,17 +9,22 @@ typedef struct example_user_t {
     UT_hash_handle alth;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL, *altusers=NULL;
 
     /* create elements */
-    for(i=0;i<1000;i++) {
+    for(i=0; i<1000; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
-        if (i<10) HASH_ADD_INT(users,id,user);
+        if (i<10) {
+            HASH_ADD_INT(users,id,user);
+        }
         HASH_ADD(alth,altusers,id,sizeof(int),user);
     }
 
@@ -42,5 +47,5 @@ int main(int argc,char *argv[]) {
     HASH_FIND(alth,altusers,&i,sizeof(int),tmp);
     printf("%d %s in alth\n", i, (tmp != NULL) ? "found" : "not found");
 
-   return 0;
+    return 0;
 }

+ 11 - 6
tests/test11.c

@@ -18,13 +18,15 @@ typedef struct name_rec {
     UT_hash_handle hh;
 } name_rec;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     name_rec *a = (name_rec*)_a;
     name_rec *b = (name_rec*)_b;
     return strcmp(a->boy_name,b->boy_name);
 }
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     name_rec *name, *names=NULL;
     char linebuf[BUFLEN];
     FILE *file;
@@ -37,16 +39,19 @@ int main(int argc,char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (name_rec*)malloc(sizeof(name_rec));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->boy_name,linebuf,sizeof(name->boy_name));
         HASH_ADD_STR(names,boy_name,name);
     }
 
     fclose(file);
     HASH_SORT(names,namecmp);
-    for(name=names; name!=NULL; name=(name_rec*)(name->hh.next))
-      printf("%s",name->boy_name);
+    for(name=names; name!=NULL; name=(name_rec*)(name->hh.next)) {
+        printf("%s",name->boy_name);
+    }
 
-   return 0;
+    return 0;
 }
 

+ 11 - 6
tests/test12.c

@@ -8,16 +8,20 @@ typedef struct person_t {
     UT_hash_handle hh;
 } person_t;
 
-int main(int argc, char*argv[]) {
+int main(int argc, char*argv[])
+{
     person_t *people=NULL, *person;
     const char **name;
     const char * names[] = { "bob", "jack", "gary", "ty", "bo", "phil", "art",
-                      "gil", "buck", "ted", NULL };
+                             "gil", "buck", "ted", NULL
+                           };
     int id=0;
 
     for(name=names; *name != NULL; name++) {
         person = (person_t*)malloc(sizeof(person_t));
-        if (person == NULL) exit(-1);
+        if (person == NULL) {
+            exit(-1);
+        }
         strncpy(person->first_name, *name,10UL);
         person->id = id++;
         HASH_ADD_STR(people,first_name,person);
@@ -26,10 +30,11 @@ int main(int argc, char*argv[]) {
 
     for(name=names; *name != NULL; name++) {
         HASH_FIND_STR(people,*name,person);
-        if (person != NULL)
+        if (person != NULL) {
             printf("found %s (id %d)\n", person->first_name, person->id);
-        else
+        } else {
             printf("failed to find %s\n", *name);
+        }
     }
-   return 0;
+    return 0;
 }

+ 14 - 7
tests/test13.c

@@ -8,26 +8,31 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     /* delete each even ID */
-    for(i=0;i<10;i+=2) {
+    for(i=0; i<10; i+=2) {
         HASH_FIND_INT(users,&i,tmp);
         if (tmp != NULL) {
             HASH_DEL(users,tmp);
             free(tmp);
-        } else printf("user id %d not found\n", i);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
 
     i=9;
@@ -37,7 +42,9 @@ int main(int argc,char *argv[]) {
             printf("id %d, following prev...\n", tmp->id);
             tmp = (example_user_t*)tmp->hh.prev;
         }
-    } else printf("user id %d not found\n", i);
+    } else {
+        printf("user id %d not found\n", i);
+    }
 
-   return 0;
+    return 0;
 }

+ 11 - 5
tests/test14.c

@@ -14,7 +14,8 @@ typedef struct name_rec {
     UT_hash_handle hh;
 } name_rec;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     name_rec *name, *names=NULL;
     char linebuf[BUFLEN];
     FILE *file;
@@ -29,7 +30,9 @@ int main(int argc,char *argv[]) {
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         i++;
         name = (name_rec*)malloc(sizeof(name_rec));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->boy_name,linebuf,sizeof(name->boy_name));
         HASH_ADD_STR(names,boy_name,name);
     }
@@ -38,11 +41,14 @@ int main(int argc,char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         HASH_FIND_STR(names,linebuf,name);
-        if (!name) printf("failed to find: %s", linebuf);
-        else j++;
+        if (!name) {
+            printf("failed to find: %s", linebuf);
+        } else {
+            j++;
+        }
     }
     fclose(file);
     printf("lookup on %d of %d names succeeded\n", j, i);
-   return 0;
+    return 0;
 }
 

+ 10 - 5
tests/test15.c

@@ -10,26 +10,31 @@ struct my_struct {
 };
 
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     const char **n, *names[] = { "joe", "bob", "betty", NULL };
     struct my_struct *s, *tmp, *users = NULL;
     int i=0;
 
     for (n = names; *n != NULL; n++) {
         s = (struct my_struct*)malloc(sizeof(struct my_struct));
-        if (s == NULL) exit(-1);
+        if (s == NULL) {
+            exit(-1);
+        }
         strncpy(s->name, *n,10UL);
         s->id = i++;
         HASH_ADD_STR( users, name, s );
     }
 
     HASH_FIND_STR( users, "betty", s);
-    if (s != NULL) printf("betty's id is %d\n", s->id);
+    if (s != NULL) {
+        printf("betty's id is %d\n", s->id);
+    }
 
     /* free the hash table contents */
     HASH_ITER(hh, users, s, tmp) {
-      HASH_DEL(users, s);
-      free(s);
+        HASH_DEL(users, s);
+        free(s);
     }
     return 0;
 }

+ 10 - 5
tests/test16.c

@@ -17,17 +17,20 @@ struct my_event {
 };
 
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     struct my_event *e, ev, *events = NULL;
     unsigned keylen;
     int i;
 
     keylen =   offsetof(struct my_event, event_code) + sizeof(char)
-             - offsetof(struct my_event, is);
+               - offsetof(struct my_event, is);
 
     for(i = 0; i < 10; i++) {
         e = (struct my_event*)malloc(sizeof(struct my_event));
-        if (e == NULL) exit(-1);
+        if (e == NULL) {
+            exit(-1);
+        }
         memset(e,0,sizeof(struct my_event));
         e->is.a = i * (60*60*24*365);          /* i years (sec)*/
         e->is.b = 0;
@@ -43,6 +46,8 @@ int main(int argc, char *argv[]) {
     ev.is.b = 0;
     ev.event_code = 'b';
     HASH_FIND( hh, events, &ev.is, keylen , e);
-    if (e != NULL) printf("found: user %d, unix time %d\n", e->user_id, e->is.a);
-   return 0;
+    if (e != NULL) {
+        printf("found: user %d, unix time %d\n", e->user_id, e->is.a);
+    }
+    return 0;
 }

+ 13 - 7
tests/test17.c

@@ -8,21 +8,25 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-static int rev(void *_a, void *_b) {
+static int rev(void *_a, void *_b)
+{
     example_user_t *a = (example_user_t*)_a;
     example_user_t *b = (example_user_t*)_b;
     printf("called for a:%d, b:%d\n",a->id, b->id);
     return (a->id - b->id);
 }
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL;
 
     /* create elements */
-    for(i=9;i>=0;i--) {
+    for(i=9; i>=0; i--) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -38,9 +42,11 @@ int main(int argc,char *argv[]) {
     }
 
     printf("adding 10-20\n");
-    for(i=20;i>=10;i--) {
+    for(i=20; i>=10; i--) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -53,5 +59,5 @@ int main(int argc,char *argv[]) {
     for(user=users; user != NULL; user=(example_user_t*)user->hh.next) {
         printf("user %d, cookie %d\n", user->id, user->cookie);
     }
-   return 0;
+    return 0;
 }

+ 9 - 6
tests/test18.c

@@ -8,14 +8,17 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -27,8 +30,8 @@ int main(int argc,char *argv[]) {
 
     /* delete them all, pathologically */
     while(users != NULL) {
-      printf("deleting id %i\n", users->id);
-      HASH_DEL(users,users); /* single head/deletee var! */
+        printf("deleting id %i\n", users->id);
+        HASH_DEL(users,users); /* single head/deletee var! */
     }
-   return 0;
+    return 0;
 }

+ 26 - 13
tests/test19.c

@@ -9,45 +9,58 @@ typedef struct example_user_t {
     UT_hash_handle alth;
 } example_user_t;
 
-static int ascending_sort(void *_a, void *_b) {
+static int ascending_sort(void *_a, void *_b)
+{
     example_user_t *a = (example_user_t*)_a;
     example_user_t *b = (example_user_t*)_b;
-    if (a->id == b->id) return 0;
+    if (a->id == b->id) {
+        return 0;
+    }
     return (a->id < b->id) ? -1 : 1;
 }
 
-static int descending_sort(void *_a, void *_b) {
+static int descending_sort(void *_a, void *_b)
+{
     example_user_t *a = (example_user_t*)_a;
     example_user_t *b = (example_user_t*)_b;
-    if (a->id == b->id) return 0;
+    if (a->id == b->id) {
+        return 0;
+    }
     return (a->id < b->id) ? 1 : -1;
 }
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL, *altusers=NULL;
 
     /* create elements */
-    for(i=0;i<1000;i++) {
+    for(i=0; i<1000; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
-        if (i<10) HASH_ADD_INT(users,id,user);
+        if (i<10) {
+            HASH_ADD_INT(users,id,user);
+        }
         HASH_ADD(alth,altusers,id,sizeof(int),user);
     }
 
     printf("sorting users ascending\n");
     HASH_SRT(hh,users,ascending_sort);
-    for(user=users; user!=NULL; user=(example_user_t*)user->hh.next)
-      printf("user %d\n", user->id);
+    for(user=users; user!=NULL; user=(example_user_t*)user->hh.next) {
+        printf("user %d\n", user->id);
+    }
 
     printf("sorting altusers descending\n");
     HASH_SRT(alth,altusers,descending_sort);
-    for(user=altusers; user!=NULL; user=(example_user_t*)user->alth.next)
-      printf("altuser %d\n", user->id);
+    for(user=altusers; user!=NULL; user=(example_user_t*)user->alth.next) {
+        printf("altuser %d\n", user->id);
+    }
 
     /* HASH_FSCK(hh,users); */
     /* HASH_FSCK(alth,altusers); */
-   return 0;
+    return 0;
 }

+ 13 - 7
tests/test2.c

@@ -9,24 +9,30 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     /* find each even ID */
-    for(i=0;i<10;i+=2) {
+    for(i=0; i<10; i+=2) {
         HASH_FIND_INT(users,&i,tmp);
-        if (tmp != NULL) printf("user id %d found, cookie %d\n", tmp->id, tmp->cookie);
-        else printf("user id %d not found\n", i);
+        if (tmp != NULL) {
+            printf("user id %d found, cookie %d\n", tmp->id, tmp->cookie);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
-   return 0;
+    return 0;
 }

+ 9 - 4
tests/test20.c

@@ -9,13 +9,16 @@ struct my_struct {
     UT_hash_handle hh;
 };
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     struct my_struct *s, *t, *bins = NULL;
     char binary[5] = {'\3','\1','\4','\1','\6'};
 
     /* allocate our structure. initialize to some values */
     s = (struct my_struct*)calloc(1UL,sizeof(struct my_struct));
-    if (s == NULL) exit(-1);
+    if (s == NULL) {
+        exit(-1);
+    }
     memcpy(s->bkey, binary, sizeof(binary));
 
     /* add to hash table using general macro */
@@ -24,6 +27,8 @@ int main(int argc, char *argv[]) {
     /* look up the structure we just added */
     HASH_FIND( hh, bins, binary, sizeof(binary), t );
 
-    if (t != NULL) printf("found\n");
-   return 0;
+    if (t != NULL) {
+        printf("found\n");
+    }
+    return 0;
 }

+ 12 - 7
tests/test21.c

@@ -3,8 +3,8 @@
 #include "uthash.h"
 
 typedef struct {
-  char a;
-  int b;
+    char a;
+    int b;
 } record_key_t;
 
 typedef struct {
@@ -13,11 +13,14 @@ typedef struct {
     UT_hash_handle hh;
 } record_t;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     record_t l, *p, *r, *tmp, *records = NULL;
 
     r = (record_t*)malloc( sizeof(record_t) );
-    if (r == NULL) exit(-1);
+    if (r == NULL) {
+        exit(-1);
+    }
     memset(r, 0, sizeof(record_t));
     r->key.a = 'a';
     r->key.b = 1;
@@ -28,11 +31,13 @@ int main(int argc, char *argv[]) {
     l.key.b = 1;
     HASH_FIND(hh, records, &l.key, sizeof(record_key_t), p);
 
-    if (p != NULL) printf("found %c %d\n", p->key.a, p->key.b);
+    if (p != NULL) {
+        printf("found %c %d\n", p->key.a, p->key.b);
+    }
 
     HASH_ITER(hh, records, p, tmp) {
-      HASH_DEL(records, p);
-      free(p);
+        HASH_DEL(records, p);
+        free(p);
     }
     return 0;
 }

+ 19 - 12
tests/test22.c

@@ -7,10 +7,10 @@
 #define UTF32 '\x1'
 
 typedef struct {
-  UT_hash_handle hh;
-  size_t len;
-  char encoding;      /* these two fields */
-  int text[];         /* comprise the key */
+    UT_hash_handle hh;
+    size_t len;
+    char encoding;      /* these two fields */
+    int text[];         /* comprise the key */
 } msg_t;
 
 typedef struct {
@@ -18,7 +18,8 @@ typedef struct {
     int text[];
 } lookup_key_t;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     unsigned keylen;
     msg_t *msg, *tmp, *msgs = NULL;
     lookup_key_t *lookup_key;
@@ -27,7 +28,9 @@ int main(int argc, char *argv[]) {
 
     /* allocate and initialize our structure */
     msg = (msg_t*)malloc( sizeof(msg_t) + sizeof(beijing) );
-    if (msg == NULL) exit(-1);
+    if (msg == NULL) {
+        exit(-1);
+    }
     memset(msg, 0, sizeof(msg_t)+sizeof(beijing)); /* zero fill */
     msg->len = sizeof(beijing);
     msg->encoding = UTF32;
@@ -35,8 +38,8 @@ int main(int argc, char *argv[]) {
 
     /* calculate the key length including padding, using formula */
     keylen =   offsetof(msg_t, text)       /* offset of last key field */
-             + sizeof(beijing)             /* size of last key field */
-             - offsetof(msg_t, encoding);  /* offset of first key field */
+               + sizeof(beijing)             /* size of last key field */
+               - offsetof(msg_t, encoding);  /* offset of first key field */
 
     /* add our structure to the hash table */
     HASH_ADD( hh, msgs, encoding, keylen, msg);
@@ -45,17 +48,21 @@ int main(int argc, char *argv[]) {
     msg=NULL;
 
     lookup_key = (lookup_key_t*)malloc(sizeof(*lookup_key) + sizeof(beijing));
-    if (lookup_key == NULL) exit(-1);
+    if (lookup_key == NULL) {
+        exit(-1);
+    }
     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 );
-    if (msg != NULL) printf("found \n");
+    if (msg != NULL) {
+        printf("found \n");
+    }
     free(lookup_key);
 
     HASH_ITER(hh, msgs, msg, tmp) {
-      HASH_DEL(msgs, msg);
-      free(msg);
+        HASH_DEL(msgs, msg);
+        free(msg);
     }
     return 0;
 }

+ 56 - 34
tests/test23.c

@@ -3,45 +3,67 @@
 #include "uthash.h"
 
 typedef struct {
-  int key;
-  int data;
-  UT_hash_handle hh;
+    int key;
+    int data;
+    UT_hash_handle hh;
 } item;
 
-int main() {
-  item *i, *j, *items=NULL;
-  int k;
+int main()
+{
+    item *i, *j, *items=NULL;
+    int k;
 
-  /* first item */
-  k = 12345;
-  i = (item*)malloc(sizeof(item));
-  if (i == NULL) exit(-1);
-  i->key = k; i->data = 0;
-  HASH_ADD_INT(items,key,i);
+    /* first item */
+    k = 12345;
+    i = (item*)malloc(sizeof(item));
+    if (i == NULL) {
+        exit(-1);
+    }
+    i->key = k;
+    i->data = 0;
+    HASH_ADD_INT(items,key,i);
 
-  /* second item */
-  k = 6789;
-  i = (item*)malloc(sizeof(item));
-  if (i == NULL) exit(-1);
-  i->key = k; i->data = 0;
-  HASH_ADD_INT(items,key,i);
+    /* second item */
+    k = 6789;
+    i = (item*)malloc(sizeof(item));
+    if (i == NULL) {
+        exit(-1);
+    }
+    i->key = k;
+    i->data = 0;
+    HASH_ADD_INT(items,key,i);
 
-  /* third item */
-  k = 98765;
-  i = (item*)malloc(sizeof(item));
-  if (i == NULL) exit(-1);
-  i->key = k; i->data = 0;
-  HASH_ADD_INT(items,key,i);
+    /* third item */
+    k = 98765;
+    i = (item*)malloc(sizeof(item));
+    if (i == NULL) {
+        exit(-1);
+    }
+    i->key = k;
+    i->data = 0;
+    HASH_ADD_INT(items,key,i);
 
-  /* look them all up */
-  k = 12345; HASH_FIND_INT(items, &k, j); if (j != NULL) printf("found %d\n",k);
-  k = 6789;  HASH_FIND_INT(items, &k, j); if (j != NULL) printf("found %d\n",k);
-  k = 98765; HASH_FIND_INT(items, &k, j); if (j != NULL) printf("found %d\n",k);
+    /* look them all up */
+    k = 12345;
+    HASH_FIND_INT(items, &k, j);
+    if (j != NULL) {
+        printf("found %d\n",k);
+    }
+    k = 6789;
+    HASH_FIND_INT(items, &k, j);
+    if (j != NULL) {
+        printf("found %d\n",k);
+    }
+    k = 98765;
+    HASH_FIND_INT(items, &k, j);
+    if (j != NULL) {
+        printf("found %d\n",k);
+    }
 
-  /* delete them not the way we prefer but it works */
-  for(j=items; j != NULL; j=(item*)j->hh.next) {
-    printf("deleting %d\n", j->key);
-    HASH_DEL(items,j);
-  }
-  return 0;
+    /* delete them not the way we prefer but it works */
+    for(j=items; j != NULL; j=(item*)j->hh.next) {
+        printf("deleting %d\n", j->key);
+        HASH_DEL(items,j);
+    }
+    return 0;
 }

+ 7 - 4
tests/test24.c

@@ -8,19 +8,22 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     printf("hash contains %u items\n", HASH_COUNT(users));
-   return 0;
+    return 0;
 }

+ 36 - 17
tests/test25.c

@@ -6,20 +6,24 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     int count;
     el els[10], *e;
     el *head = NULL;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL macros\n");
     CDL_PREPEND(head,&els[0]);
     CDL_PREPEND(head,&els[1]);
     CDL_PREPEND(head,&els[2]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     CDL_COUNT(head,e, count);
     printf("count = %d\n", count);
@@ -27,33 +31,40 @@ int main(int argc, char *argv[]) {
     /* point head to head->next */
     printf("advancing head pointer\n");
     head = head->next;
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->next)
+    for(i=0,e=head; e && i<10; i++,e=e->next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop backwards a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->prev)
+    for(i=0,e=head; e && i<10; i++,e=e->prev) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     CDL_DELETE(head,&els[1]);
-    CDL_FOREACH(head,e) printf("%c ", e->id);
+    CDL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (a)\n");
     CDL_DELETE(head,&els[0]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (c)\n");
     CDL_DELETE(head,&els[2]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test DL macros */
@@ -61,28 +72,32 @@ int main(int argc, char *argv[]) {
     DL_APPEND(head,&els[0]);
     DL_APPEND(head,&els[1]);
     DL_APPEND(head,&els[2]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     DL_COUNT(head,e, count);
     printf("count = %d\n", count);
 
     printf("deleting tail c\n");
     DL_DELETE(head,&els[2]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head a\n");
     DL_DELETE(head,&els[0]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head b\n");
     DL_DELETE(head,&els[1]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test LL macros */
@@ -90,8 +105,9 @@ int main(int argc, char *argv[]) {
     LL_APPEND(head,&els[0]);
     LL_APPEND(head,&els[1]);
     LL_APPEND(head,&els[2]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     LL_COUNT(head,e,count);
@@ -99,20 +115,23 @@ int main(int argc, char *argv[]) {
 
     printf("deleting tail c\n");
     LL_DELETE(head,&els[2]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head a\n");
     LL_DELETE(head,&els[0]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head b\n");
     LL_DELETE(head,&els[1]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     return 0;

+ 14 - 6
tests/test26.c

@@ -10,13 +10,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     el *a = (el*)_a;
     el *b = (el*)_b;
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *elt, *tmp, etmp;
     el *head = NULL; /* important- initialize to NULL! */
 
@@ -31,20 +33,26 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         DL_APPEND(head, name);
     }
     DL_SORT(head, namecmp);
-    DL_FOREACH(head,elt) printf("%s", elt->bname);
+    DL_FOREACH(head,elt) {
+        printf("%s", elt->bname);
+    }
 
     memcpy(etmp.bname, "WES\n", 5UL);
     DL_SEARCH(head,elt,&etmp,namecmp);
-    if (elt != NULL) printf("found %s\n", elt->bname);
+    if (elt != NULL) {
+        printf("found %s\n", elt->bname);
+    }
 
     /* now delete each element, use the safe iterator */
     DL_FOREACH_SAFE(head,elt,tmp) {
-      DL_DELETE(head,elt);
+        DL_DELETE(head,elt);
     }
 
     fclose(file);

+ 36 - 17
tests/test27.c

@@ -6,51 +6,62 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[10], *e;
     el *head = NULL;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL macros\n");
     CDL_PREPEND(head,&els[0]);
     CDL_PREPEND(head,&els[1]);
     CDL_PREPEND(head,&els[2]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* point head to head->next */
     printf("advancing head pointer\n");
     head = head->next;
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->next)
+    for(i=0,e=head; e && i<10; i++,e=e->next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop backwards a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->prev)
+    for(i=0,e=head; e && i<10; i++,e=e->prev) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     CDL_DELETE(head,&els[1]);
-    CDL_FOREACH(head,e) printf("%c ", e->id);
+    CDL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting head (a)\n");
     CDL_DELETE(head,&els[0]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting new head (c)\n");
     CDL_DELETE(head,&els[2]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test DL macros */
@@ -58,26 +69,30 @@ int main(int argc, char *argv[]) {
     DL_PREPEND(head,&els[0]);
     DL_PREPEND(head,&els[1]);
     DL_PREPEND(head,&els[2]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting c\n");
     DL_DELETE(head,&els[2]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting a\n");
     DL_DELETE(head,&els[0]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     DL_DELETE(head,&els[1]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test LL macros */
@@ -85,26 +100,30 @@ int main(int argc, char *argv[]) {
     LL_PREPEND(head,&els[0]);
     LL_PREPEND(head,&els[1]);
     LL_PREPEND(head,&els[2]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting c\n");
     LL_DELETE(head,&els[2]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting a\n");
     LL_DELETE(head,&els[0]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     LL_DELETE(head,&els[1]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     return 0;

+ 42 - 20
tests/test28.c

@@ -6,11 +6,14 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[10], *e;
     el *head = NULL;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL macros\n");
@@ -18,45 +21,54 @@ int main(int argc, char *argv[]) {
     CDL_PREPEND(head,&els[1]);
     CDL_PREPEND(head,&els[2]);
     CDL_PREPEND(head,&els[3]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* point head to head->next */
     printf("advancing head pointer\n");
     head = head->next;
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->next)
+    for(i=0,e=head; e && i<10; i++,e=e->next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop backwards a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->prev)
+    for(i=0,e=head; e && i<10; i++,e=e->prev) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     CDL_DELETE(head,&els[1]);
-    CDL_FOREACH(head,e) printf("%c ", e->id);
+    CDL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (a)\n");
     CDL_DELETE(head,&els[0]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (c)\n");
     CDL_DELETE(head,&els[2]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (d)\n");
     CDL_DELETE(head,&els[3]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test DL macros */
@@ -65,32 +77,37 @@ int main(int argc, char *argv[]) {
     DL_PREPEND(head,&els[1]);
     DL_PREPEND(head,&els[2]);
     DL_APPEND(head,&els[3]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting c\n");
     DL_DELETE(head,&els[2]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting a\n");
     DL_DELETE(head,&els[0]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     DL_DELETE(head,&els[1]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting d\n");
     DL_DELETE(head,&els[3]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test LL macros */
@@ -99,32 +116,37 @@ int main(int argc, char *argv[]) {
     LL_PREPEND(head,&els[1]);
     LL_PREPEND(head,&els[2]);
     LL_APPEND(head,&els[3]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting c\n");
     LL_DELETE(head,&els[2]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting a\n");
     LL_DELETE(head,&els[0]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     LL_DELETE(head,&els[1]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting d\n");
     LL_DELETE(head,&els[3]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     return 0;

+ 13 - 5
tests/test29.c

@@ -10,13 +10,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     el *a = (el*)_a;
     el *b = (el*)_b;
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *tmp;
     el *head = NULL;
 
@@ -31,17 +33,23 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         DL_APPEND(head, name);
     }
     DL_SORT(head, namecmp);
-    DL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    DL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     /* now delete the list head */
     printf("deleting head %shead->prev: %s", head->bname, head->prev->bname);
     DL_DELETE(head,head);
-    DL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    DL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     fclose(file);
 

+ 11 - 6
tests/test3.c

@@ -8,31 +8,36 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     /* delete each even ID */
-    for(i=0;i<10;i+=2) {
+    for(i=0; i<10; i+=2) {
         HASH_FIND_INT(users,&i,tmp);
         if (tmp != NULL) {
             HASH_DEL(users,tmp);
             free(tmp);
-        } else printf("user id %d not found\n", i);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
 
     /* show the hash */
     for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {
         printf("user %d, cookie %d\n", user->id, user->cookie);
     }
-   return 0;
+    return 0;
 }

+ 10 - 4
tests/test30.c

@@ -10,13 +10,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     el *a = (el*)_a;
     el *b = (el*)_b;
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *tmp;
     el *head = NULL;
 
@@ -31,12 +33,16 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         CDL_PREPEND(head, name);
     }
     CDL_SORT(head, namecmp);
-    CDL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    CDL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     fclose(file);
 

+ 10 - 4
tests/test31.c

@@ -10,13 +10,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     el *a = (el*)_a;
     el *b = (el*)_b;
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *tmp;
     el *head = NULL;
 
@@ -31,12 +33,16 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         CDL_PREPEND(head, name);
     }
     CDL_SORT(head, namecmp);
-    CDL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    CDL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     fclose(file);
 

+ 10 - 4
tests/test32.c

@@ -10,11 +10,13 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(el *a, el *b) {
+static int namecmp(el *a, el *b)
+{
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *tmp;
     el *head = NULL;
 
@@ -29,12 +31,16 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         DL_PREPEND(head, name);
     }
     /* DL_SORT(head, namecmp); */
-    DL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    DL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     fclose(file);
 

+ 10 - 4
tests/test33.c

@@ -10,13 +10,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     el *a = (el*)_a;
     el *b = (el*)_b;
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *tmp;
     el *head = NULL;
 
@@ -31,12 +33,16 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         LL_PREPEND(head, name);
     }
     LL_SORT(head, namecmp);
-    LL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    LL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     fclose(file);
 

+ 10 - 4
tests/test34.c

@@ -10,11 +10,13 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(el *a, el *b) {
+static int namecmp(el *a, el *b)
+{
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *tmp;
     el *head = NULL;
 
@@ -29,12 +31,16 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         CDL_PREPEND(head, name);
     }
     /* CDL_SORT(head, namecmp); */
-    CDL_FOREACH(head,tmp) printf("%s", tmp->bname);
+    CDL_FOREACH(head,tmp) {
+        printf("%s", tmp->bname);
+    }
 
     fclose(file);
 

+ 16 - 15
tests/test35.c

@@ -8,29 +8,30 @@ typedef struct elt {
     UT_hash_handle hh;
 } elt;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     elt *head = NULL;
     elt elts[10];
     char label[6];
-    for(i=0;i<10;i++) {
-      elts[i].s = (char*)malloc(6UL);
-      strncpy(elts[i].s, "hello",6UL);
-      elts[i].s[0] = 'a' + i;
-      printf("%d: %s\n", i, elts[i].s);
-      HASH_ADD_KEYPTR(hh, head, elts[i].s, 6UL, &elts[i]);
+    for(i=0; i<10; i++) {
+        elts[i].s = (char*)malloc(6UL);
+        strncpy(elts[i].s, "hello",6UL);
+        elts[i].s[0] = 'a' + i;
+        printf("%d: %s\n", i, elts[i].s);
+        HASH_ADD_KEYPTR(hh, head, elts[i].s, 6UL, &elts[i]);
     }
 
     /* look up each element and verify the result pointer */
     strncpy(label, "hello", sizeof(label));
-    for(i=0;i<10;i++) {
-      elt *e;
-      label[0] = 'a' + i;
-      HASH_FIND(hh,head,label,6UL,e);
-      if (e != NULL) {
-        printf( "found %s\n", e->s);
-        printf( "right address? %s\n", (e == &elts[i]) ? "yes" : "no");
-      }
+    for(i=0; i<10; i++) {
+        elt *e;
+        label[0] = 'a' + i;
+        HASH_FIND(hh,head,label,6UL,e);
+        if (e != NULL) {
+            printf( "found %s\n", e->s);
+            printf( "right address? %s\n", (e == &elts[i]) ? "yes" : "no");
+        }
     }
 
     return 0;

+ 16 - 11
tests/test36.c

@@ -9,25 +9,30 @@ typedef struct {
 } example_user_t;
 
 #define EVENS(x) (((x)->id % 2) == 0)
-static int evens(void *userv) {
-  example_user_t *user = (example_user_t*)userv;
-  return ((user->id % 2) ? 0 : 1);
+static int evens(void *userv)
+{
+    example_user_t *user = (example_user_t*)userv;
+    return ((user->id % 2) ? 0 : 1);
 }
 
-static int idcmp(void *_a, void *_b) {
-  example_user_t *a = (example_user_t*)_a;
-  example_user_t *b = (example_user_t*)_b;
-  return (a->id - b->id);
+static int idcmp(void *_a, void *_b)
+{
+    example_user_t *a = (example_user_t*)_a;
+    example_user_t *b = (example_user_t*)_b;
+    return (a->id - b->id);
 }
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL, *ausers=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         HASH_ADD_INT(users,id,user);
     }
@@ -43,5 +48,5 @@ int main(int argc,char *argv[]) {
     for(user=ausers; user!=NULL; user=(example_user_t*)(user->ah.next)) {
         printf("auser %d\n", user->id);
     }
-   return 0;
+    return 0;
 }

+ 12 - 8
tests/test37.c

@@ -10,20 +10,24 @@ typedef struct {
 
 #define EVENS(x) ((((example_user_t*)(x))->id % 2) == 0)
 
-static int idcmp(void *_a, void *_b) {
-  example_user_t *a = (example_user_t*)_a;
-  example_user_t *b = (example_user_t*)_b;
-  return (a->id - b->id);
+static int idcmp(void *_a, void *_b)
+{
+    example_user_t *a = (example_user_t*)_a;
+    example_user_t *b = (example_user_t*)_b;
+    return (a->id - b->id);
 }
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL, *ausers=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         HASH_ADD_INT(users,id,user);
     }
@@ -48,5 +52,5 @@ int main(int argc,char *argv[]) {
         printf("auser %d\n", user->id);
     }
     printf("users count: %u\n", HASH_CNT(hh,users));
-   return 0;
+    return 0;
 }

+ 22 - 19
tests/test38.c

@@ -3,26 +3,29 @@
 #include <stdio.h>
 
 struct test_t {
-  int a;
-  UT_hash_handle hh;
+    int a;
+    UT_hash_handle hh;
 };
 
-int main(void) {
-  struct test_t *tests=NULL, *test;
-  int a, b;
-  for (b=0; b < 3; b++) {
-    for (a=0; a < 10; a++) {
-      test = NULL;
-      HASH_FIND(hh, tests, &a, sizeof(a), test);
-      if (test == NULL) {
-        test = (struct test_t*)malloc(sizeof(struct test_t));
-        if (test == NULL) exit(-1);
-        memset(test, 0, sizeof(struct test_t));
-        test->a = a;
-        HASH_ADD(hh, tests, a, sizeof(a), test);
-      }
+int main(void)
+{
+    struct test_t *tests=NULL, *test;
+    int a, b;
+    for (b=0; b < 3; b++) {
+        for (a=0; a < 10; a++) {
+            test = NULL;
+            HASH_FIND(hh, tests, &a, sizeof(a), test);
+            if (test == NULL) {
+                test = (struct test_t*)malloc(sizeof(struct test_t));
+                if (test == NULL) {
+                    exit(-1);
+                }
+                memset(test, 0, sizeof(struct test_t));
+                test->a = a;
+                HASH_ADD(hh, tests, a, sizeof(a), test);
+            }
+        }
     }
-  }
-  printf("hash count %u\n", HASH_COUNT(tests));
-  return 0;
+    printf("hash count %u\n", HASH_COUNT(tests));
+    return 0;
 }

+ 24 - 21
tests/test39.c

@@ -3,29 +3,32 @@
 #include "uthash.h"
 
 typedef struct {
-  const char *name;
-  UT_hash_handle hh;
+    const char *name;
+    UT_hash_handle hh;
 } ns_t;
 
-int main() {
-  const char *keys[] = {"eins", "zwei", "drei"};
-  unsigned i;
-  ns_t *nsp;
-  ns_t *head = NULL;
+int main()
+{
+    const char *keys[] = {"eins", "zwei", "drei"};
+    unsigned i;
+    ns_t *nsp;
+    ns_t *head = NULL;
 
-  for(i=0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
-    printf("adding key %s\n", keys[i]);
-    nsp = (ns_t*)malloc(sizeof(ns_t));
-    if (nsp == NULL) exit(-1);
-    nsp->name = keys[i];
-    HASH_ADD_KEYPTR(hh,head,nsp->name,strlen(nsp->name),nsp);
-  }
-  printf("hash count is %u\n", HASH_COUNT(head));
+    for(i=0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
+        printf("adding key %s\n", keys[i]);
+        nsp = (ns_t*)malloc(sizeof(ns_t));
+        if (nsp == NULL) {
+            exit(-1);
+        }
+        nsp->name = keys[i];
+        HASH_ADD_KEYPTR(hh,head,nsp->name,strlen(nsp->name),nsp);
+    }
+    printf("hash count is %u\n", HASH_COUNT(head));
 
-  for(i=0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
-    printf("looking for key %s... ", keys[i]);
-    HASH_FIND(hh,head,keys[i],strlen(keys[i]),nsp);
-    printf("%s.\n", (nsp!=NULL)?"found":"not found");
-  }
-  return 0;
+    for(i=0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
+        printf("looking for key %s... ", keys[i]);
+        HASH_FIND(hh,head,keys[i],strlen(keys[i]),nsp);
+        printf("%s.\n", (nsp!=NULL)?"found":"not found");
+    }
+    return 0;
 }

+ 7 - 4
tests/test4.c

@@ -9,14 +9,17 @@ typedef struct example_user_t {
     UT_hash_handle alth;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL, *altusers=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -26,5 +29,5 @@ int main(int argc,char *argv[]) {
     for(user=altusers; user != NULL; user=(example_user_t*)(user->alth.next)) {
         printf("cookie %d, user %d\n", user->cookie, user->id);
     }
-   return 0;
+    return 0;
 }

+ 10 - 5
tests/test40.c

@@ -10,26 +10,31 @@ struct my_struct {
 };
 
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     const char **n, *names[] = { "joe", "bob", "betty", NULL };
     struct my_struct *s, *tmp, *users = NULL;
     int i=0;
 
     for (n = names; *n != NULL; n++) {
         s = (struct my_struct*)malloc(sizeof(struct my_struct));
-        if (s == NULL) exit(-1);
+        if (s == NULL) {
+            exit(-1);
+        }
         s->name = *n;
         s->id = i++;
         HASH_ADD_KEYPTR( hh, users, s->name, strlen(s->name), s );
     }
 
     HASH_FIND_STR( users, "betty", s);
-    if (s != NULL) printf("betty's id is %d\n", s->id);
+    if (s != NULL) {
+        printf("betty's id is %d\n", s->id);
+    }
 
     /* free the hash table contents */
     HASH_ITER(hh, users, s, tmp) {
-      HASH_DEL(users, s);
-      free(s);
+        HASH_DEL(users, s);
+        free(s);
     }
     return 0;
 }

+ 23 - 8
tests/test41.c

@@ -6,18 +6,23 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el *head = NULL;
     el els[10], *e, *tmp, *tmp2;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL macros\n");
     CDL_PREPEND(head,&els[0]);
     CDL_PREPEND(head,&els[1]);
     CDL_PREPEND(head,&els[2]);
-    CDL_FOREACH(head,e) printf("%c ", e->id);
+    CDL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
 
     /* point head to head->next */
     CDL_FOREACH_SAFE(head,e,tmp,tmp2) {
@@ -25,33 +30,43 @@ int main(int argc, char *argv[]) {
         CDL_DELETE(head,e);
     }
     printf("\n");
-    if (head != NULL) printf("non-null head\n");
+    if (head != NULL) {
+        printf("non-null head\n");
+    }
 
     /* test DL macros */
     printf("DL macros\n");
     DL_APPEND(head,&els[0]);
     DL_APPEND(head,&els[1]);
     DL_APPEND(head,&els[2]);
-    DL_FOREACH(head,e) printf("%c ", e->id);
+    DL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
     DL_FOREACH_SAFE(head,e,tmp) {
         printf("deleting %c ", e->id);
         DL_DELETE(head,e);
     }
     printf("\n");
-    if (head != NULL) printf("non-null head\n");
+    if (head != NULL) {
+        printf("non-null head\n");
+    }
 
     /* test LL macros */
     printf("LL macros\n");
     LL_APPEND(head,&els[0]);
     LL_APPEND(head,&els[1]);
     LL_APPEND(head,&els[2]);
-    LL_FOREACH(head,e) printf("%c ", e->id);
+    LL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
     LL_FOREACH_SAFE(head,e,tmp) {
         printf("deleting %c ", e->id);
         LL_DELETE(head,e);
     }
     printf("\n");
-    if (head != NULL) printf("non-null head\n");
+    if (head != NULL) {
+        printf("non-null head\n");
+    }
 
     return 0;
 }

+ 42 - 16
tests/test42.c

@@ -6,27 +6,40 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int eltcmp(el *a, el *b) {return a->id - b->id;}
+static int eltcmp(el *a, el *b)
+{
+    return a->id - b->id;
+}
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el *head = NULL;
     el els[10], *e, *tmp, *tmp2;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test LL macros */
     printf("LL macros\n");
     LL_APPEND(head,&els[0]);
     LL_APPEND(head,&els[1]);
     LL_APPEND(head,&els[2]);
-    LL_FOREACH(head,e)
+    LL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     LL_SEARCH_SCALAR(head, e, id, 'b');
-    if (e != NULL) printf("search scalar found b\n");
+    if (e != NULL) {
+        printf("search scalar found b\n");
+    }
     LL_SEARCH(head, e, &els[0], eltcmp);
-    if (e != NULL) printf("search found %c\n",e->id);
-    LL_FOREACH_SAFE(head,e,tmp) LL_DELETE(head,e);
+    if (e != NULL) {
+        printf("search found %c\n",e->id);
+    }
+    LL_FOREACH_SAFE(head,e,tmp) {
+        LL_DELETE(head,e);
+    }
 
     printf("\n");
 
@@ -35,14 +48,21 @@ int main(int argc, char *argv[]) {
     DL_APPEND(head,&els[0]);
     DL_APPEND(head,&els[1]);
     DL_APPEND(head,&els[2]);
-    DL_FOREACH(head,e)
+    DL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     DL_SEARCH_SCALAR(head, e, id, 'b');
-    if (e != NULL) printf("search scalar found b\n");
+    if (e != NULL) {
+        printf("search scalar found b\n");
+    }
     DL_SEARCH(head, e, &els[0], eltcmp);
-    if (e != NULL) printf("search found %c\n",e->id);
-    DL_FOREACH_SAFE(head,e,tmp) DL_DELETE(head,e);
+    if (e != NULL) {
+        printf("search found %c\n",e->id);
+    }
+    DL_FOREACH_SAFE(head,e,tmp) {
+        DL_DELETE(head,e);
+    }
     printf("\n");
 
     /* test CDL macros */
@@ -50,15 +70,21 @@ int main(int argc, char *argv[]) {
     CDL_PREPEND(head,&els[0]);
     CDL_PREPEND(head,&els[1]);
     CDL_PREPEND(head,&els[2]);
-    CDL_FOREACH(head,e)
+    CDL_FOREACH(head,e) {
         printf("%c ", e->id);
+    }
     printf("\n");
     CDL_SEARCH_SCALAR(head, e, id, 'b');
-    if (e != NULL) printf("search scalar found b\n");
+    if (e != NULL) {
+        printf("search scalar found b\n");
+    }
     CDL_SEARCH(head, e, &els[0], eltcmp);
-    if (e != NULL) printf("search found %c\n",e->id);
-    CDL_FOREACH_SAFE(head,e,tmp,tmp2) CDL_DELETE(head,e);
-
+    if (e != NULL) {
+        printf("search found %c\n",e->id);
+    }
+    CDL_FOREACH_SAFE(head,e,tmp,tmp2) {
+        CDL_DELETE(head,e);
+    }
 
     return 0;
 }

+ 121 - 66
tests/test43.c

@@ -6,70 +6,125 @@ typedef struct {
     int b;
 } intpair_t;
 
-int main() {
-  UT_array *pairs, *pairs_cpy;
-  intpair_t it, *ip;
-  UT_icd pairicd = { sizeof(intpair_t),NULL,NULL,NULL};
-  size_t zero=0;
-  utarray_new(pairs, &pairicd);
-  printf("length is %u\n", utarray_len(pairs));
-  it.a = 1; it.b=2; utarray_push_back(pairs, &it); printf("push\n");
-  printf("length is %u\n", utarray_len(pairs));
-  ip = (intpair_t*)utarray_back(pairs);
-  printf("back is %d %d\n", ip->a, ip->b);
-  utarray_pop_back(pairs); printf("pop\n");
-  printf("length is %u\n", utarray_len(pairs));
-  it.a = 1; it.b=2; utarray_push_back(pairs, &it); printf("push\n");
-  it.a = 3; it.b=4; utarray_push_back(pairs, &it); printf("push\n");
-  printf("length is %u\n", utarray_len(pairs));
-  ip=NULL;
-  while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) printf("%d %d\n", ip->a, ip->b);
-  utarray_erase(pairs,0,1); printf("erase [0]\n");
-  printf("length is %u\n", utarray_len(pairs));
-  while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) printf("%d %d\n", ip->a, ip->b);
-  it.a = 1; it.b=2; utarray_push_back(pairs, &it); printf("push\n");
-  while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) printf("%d %d\n", ip->a, ip->b);
-  utarray_clear(pairs); printf("clear\n");
-  printf("length is %u\n", utarray_len(pairs));
-  utarray_extend_back(pairs); printf("extend\n");
-  ip = (intpair_t*)utarray_back(pairs);
-  printf("length is %u\n", utarray_len(pairs));
-  printf("ip points to [0] ? %s\n", (ip==(intpair_t*)utarray_front(pairs)) ? "yes" : "no");
-  it.a = 1; it.b=2; utarray_push_back(pairs, &it); printf("push\n");
-  ip=NULL;
-  while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) printf("%d %d\n", ip->a, ip->b);
-  utarray_erase(pairs,1,1); printf("erase [1]\n");
-  printf("length is %u\n", utarray_len(pairs));
-  while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) printf("%d %d\n", ip->a, ip->b);
-  it.a = 3; it.b=4; utarray_push_back(pairs, &it); printf("push\n");
-  for(ip=(intpair_t*)utarray_front(pairs);ip!=NULL;ip=(intpair_t*)utarray_next(pairs,ip)) {
-    printf("%d %d\n", ip->a,ip->b);
-  }
-  ip = (intpair_t*)utarray_back(pairs);
-  printf("back is %d %d\n", ip->a, ip->b);
-  utarray_new(pairs_cpy, &pairicd);
-  utarray_concat(pairs_cpy, pairs);  printf("copy\n");
-  printf("cpy length is %u\n", utarray_len(pairs_cpy));
-  ip=NULL;
-  while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) printf("cpy %d %d\n", ip->a, ip->b);
-  it.a=5; it.b=6; utarray_insert(pairs_cpy, &it, 0); printf("insert cpy[0]\n");
-  printf("cpy length is %u\n", utarray_len(pairs_cpy));
-  while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) printf("cpy %d %d\n", ip->a, ip->b);
-  utarray_erase(pairs_cpy,0,2); printf("erase cpy [0] [1]\n");
-  printf("cpy length is %u\n", utarray_len(pairs_cpy));
-  while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) printf("cpy %d %d\n", ip->a, ip->b);
-  utarray_inserta(pairs_cpy, pairs, 1); printf("inserta at cpy[1]\n");
-  printf("cpy length is %u\n", utarray_len(pairs_cpy));
-  while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) printf("cpy %d %d\n", ip->a, ip->b);
-  utarray_free(pairs_cpy); printf("free cpy\n");
-  printf("length is %u\n", utarray_len(pairs));
-  utarray_resize(pairs, 30); printf("resize to 30\n");
-  printf("length is %u\n", utarray_len(pairs));
-  while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) printf("%d %d\n", ip->a, ip->b);
-  utarray_resize(pairs, 1); printf("resize to 1\n");
-  printf("length is %u\n", utarray_len(pairs));
-  utarray_resize(pairs, zero); printf("resize to 0\n");
-  printf("length is %u\n", utarray_len(pairs));
-  utarray_free(pairs); printf("free\n");
-  return 0;
+int main()
+{
+    UT_array *pairs, *pairs_cpy;
+    intpair_t it, *ip;
+    UT_icd pairicd = { sizeof(intpair_t),NULL,NULL,NULL};
+    size_t zero=0;
+    utarray_new(pairs, &pairicd);
+    printf("length is %u\n", utarray_len(pairs));
+    it.a = 1;
+    it.b=2;
+    utarray_push_back(pairs, &it);
+    printf("push\n");
+    printf("length is %u\n", utarray_len(pairs));
+    ip = (intpair_t*)utarray_back(pairs);
+    printf("back is %d %d\n", ip->a, ip->b);
+    utarray_pop_back(pairs);
+    printf("pop\n");
+    printf("length is %u\n", utarray_len(pairs));
+    it.a = 1;
+    it.b=2;
+    utarray_push_back(pairs, &it);
+    printf("push\n");
+    it.a = 3;
+    it.b=4;
+    utarray_push_back(pairs, &it);
+    printf("push\n");
+    printf("length is %u\n", utarray_len(pairs));
+    ip=NULL;
+    while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) {
+        printf("%d %d\n", ip->a, ip->b);
+    }
+    utarray_erase(pairs,0,1);
+    printf("erase [0]\n");
+    printf("length is %u\n", utarray_len(pairs));
+    while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) {
+        printf("%d %d\n", ip->a, ip->b);
+    }
+    it.a = 1;
+    it.b=2;
+    utarray_push_back(pairs, &it);
+    printf("push\n");
+    while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) {
+        printf("%d %d\n", ip->a, ip->b);
+    }
+    utarray_clear(pairs);
+    printf("clear\n");
+    printf("length is %u\n", utarray_len(pairs));
+    utarray_extend_back(pairs);
+    printf("extend\n");
+    ip = (intpair_t*)utarray_back(pairs);
+    printf("length is %u\n", utarray_len(pairs));
+    printf("ip points to [0] ? %s\n", (ip==(intpair_t*)utarray_front(pairs)) ? "yes" : "no");
+    it.a = 1;
+    it.b=2;
+    utarray_push_back(pairs, &it);
+    printf("push\n");
+    ip=NULL;
+    while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) {
+        printf("%d %d\n", ip->a, ip->b);
+    }
+    utarray_erase(pairs,1,1);
+    printf("erase [1]\n");
+    printf("length is %u\n", utarray_len(pairs));
+    while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) {
+        printf("%d %d\n", ip->a, ip->b);
+    }
+    it.a = 3;
+    it.b=4;
+    utarray_push_back(pairs, &it);
+    printf("push\n");
+    for(ip=(intpair_t*)utarray_front(pairs); ip!=NULL; ip=(intpair_t*)utarray_next(pairs,ip)) {
+        printf("%d %d\n", ip->a,ip->b);
+    }
+    ip = (intpair_t*)utarray_back(pairs);
+    printf("back is %d %d\n", ip->a, ip->b);
+    utarray_new(pairs_cpy, &pairicd);
+    utarray_concat(pairs_cpy, pairs);
+    printf("copy\n");
+    printf("cpy length is %u\n", utarray_len(pairs_cpy));
+    ip=NULL;
+    while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) {
+        printf("cpy %d %d\n", ip->a, ip->b);
+    }
+    it.a=5;
+    it.b=6;
+    utarray_insert(pairs_cpy, &it, 0);
+    printf("insert cpy[0]\n");
+    printf("cpy length is %u\n", utarray_len(pairs_cpy));
+    while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) {
+        printf("cpy %d %d\n", ip->a, ip->b);
+    }
+    utarray_erase(pairs_cpy,0,2);
+    printf("erase cpy [0] [1]\n");
+    printf("cpy length is %u\n", utarray_len(pairs_cpy));
+    while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) {
+        printf("cpy %d %d\n", ip->a, ip->b);
+    }
+    utarray_inserta(pairs_cpy, pairs, 1);
+    printf("inserta at cpy[1]\n");
+    printf("cpy length is %u\n", utarray_len(pairs_cpy));
+    while( (ip=(intpair_t*)utarray_next(pairs_cpy,ip)) != NULL ) {
+        printf("cpy %d %d\n", ip->a, ip->b);
+    }
+    utarray_free(pairs_cpy);
+    printf("free cpy\n");
+    printf("length is %u\n", utarray_len(pairs));
+    utarray_resize(pairs, 30);
+    printf("resize to 30\n");
+    printf("length is %u\n", utarray_len(pairs));
+    while( (ip=(intpair_t*)utarray_next(pairs,ip)) != NULL ) {
+        printf("%d %d\n", ip->a, ip->b);
+    }
+    utarray_resize(pairs, 1);
+    printf("resize to 1\n");
+    printf("length is %u\n", utarray_len(pairs));
+    utarray_resize(pairs, zero);
+    printf("resize to 0\n");
+    printf("length is %u\n", utarray_len(pairs));
+    utarray_free(pairs);
+    printf("free\n");
+    return 0;
 }

+ 56 - 34
tests/test44.c

@@ -1,44 +1,66 @@
 #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;
     return _b - _a;
 }
 
-int main() {
-  UT_array *a;
-  int i, *p;
-  utarray_new(a, &ut_int_icd);
-  for(i=0;i<10;i++) utarray_push_back(a,&i);
-  for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) printf("%d ",*p);
-  printf("\n");
-  utarray_sort(a,reverse);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_erase(a,3,3);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_erase(a,1,2);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_erase(a,0,1);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_erase(a,3,1);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_resize(a,5);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_resize(a,3);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_erase(a,0,3);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p);
-  printf("\n");
-  utarray_free(a);
-  return 0;
+int main()
+{
+    UT_array *a;
+    int i, *p;
+    utarray_new(a, &ut_int_icd);
+    for(i=0; i<10; i++) {
+        utarray_push_back(a,&i);
+    }
+    for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    utarray_sort(a,reverse);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_erase(a,3,3);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_erase(a,1,2);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_erase(a,0,1);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_erase(a,3,1);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_resize(a,5);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_resize(a,3);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_erase(a,0,3);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    utarray_free(a);
+    return 0;
 }
 

+ 31 - 19
tests/test45.c

@@ -1,24 +1,36 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *a;
-  int i, *p=NULL;
-  utarray_new(a, &ut_int_icd);
-  for(i=0;i<10;i++) utarray_push_back(a,&i);
-  utarray_pop_back(a);
-  utarray_erase(a,0,1);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ",*p); printf("\n");
-  i = 100;
-  utarray_insert(a,&i,3);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ",*p); printf("\n");
-  utarray_extend_back(a);
-  p = (int*)utarray_back(a);
-  *p = 1000;
-  p = NULL;
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ",*p); printf("\n");
-  utarray_clear(a);
-  utarray_free(a);
-  return 0;
+int main()
+{
+    UT_array *a;
+    int i, *p=NULL;
+    utarray_new(a, &ut_int_icd);
+    for(i=0; i<10; i++) {
+        utarray_push_back(a,&i);
+    }
+    utarray_pop_back(a);
+    utarray_erase(a,0,1);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    i = 100;
+    utarray_insert(a,&i,3);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    utarray_extend_back(a);
+    p = (int*)utarray_back(a);
+    *p = 1000;
+    p = NULL;
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    utarray_clear(a);
+    utarray_free(a);
+    return 0;
 }
 

+ 76 - 41
tests/test46.c

@@ -1,49 +1,84 @@
 #include <stdio.h>
 #include "utarray.h"
 
-static int strsort(const void *_a, const void *_b) {
-  char *a = *(char**)_a;
-  char *b = *(char**)_b;
-  return strcmp(a,b);
+static int strsort(const void *_a, const void *_b)
+{
+    char *a = *(char**)_a;
+    char *b = *(char**)_b;
+    return strcmp(a,b);
 }
 
-static int revsort(const void *_a, const void *_b) {
-  char *a = *(char**)_a;
-  char *b = *(char**)_b;
-  return strcmp(b,a);
+static int revsort(const void *_a, const void *_b)
+{
+    char *a = *(char**)_a;
+    char *b = *(char**)_b;
+    return strcmp(b,a);
 }
 
-int main() {
-  UT_array *strs,*strs2;
-  char *s, **p=NULL;
-  utarray_new(strs, &ut_str_icd);
-  s="hello"; utarray_push_back(strs, &s);
-  s="world"; utarray_push_back(strs, &s);
-  while ( (p=(char**)utarray_next(strs,p)) != NULL ) printf("%s ",*p); printf("\n");
-  s="begin"; utarray_insert(strs,&s,0);
-  while ( (p=(char**)utarray_next(strs,p)) != NULL ) printf("%s ",*p); printf("\n");
-  utarray_new(strs2, &ut_str_icd);
-  s="alt"; utarray_push_back(strs2, &s);
-  s="oth"; utarray_push_back(strs2, &s);
-  utarray_inserta(strs2, strs, 1);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  utarray_erase(strs2,0,2);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  utarray_pop_back(strs2);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  utarray_concat(strs2, strs);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  utarray_clear(strs2);
-  utarray_concat(strs2, strs);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  printf("sorting strs2\n");
-  utarray_sort(strs2,strsort);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  printf("reverse sorting strs2\n");
-  utarray_sort(strs2,revsort);
-  while ( (p=(char**)utarray_next(strs2,p)) != NULL ) printf("%s ",*p); printf("\n");
-  utarray_clear(strs2);
-  utarray_free(strs2);
-  utarray_free(strs);
-  return 0;
+int main()
+{
+    UT_array *strs,*strs2;
+    char *s, **p=NULL;
+    utarray_new(strs, &ut_str_icd);
+    s="hello";
+    utarray_push_back(strs, &s);
+    s="world";
+    utarray_push_back(strs, &s);
+    while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    s="begin";
+    utarray_insert(strs,&s,0);
+    while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    utarray_new(strs2, &ut_str_icd);
+    s="alt";
+    utarray_push_back(strs2, &s);
+    s="oth";
+    utarray_push_back(strs2, &s);
+    utarray_inserta(strs2, strs, 1);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    utarray_erase(strs2,0,2);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    utarray_pop_back(strs2);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    utarray_concat(strs2, strs);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    utarray_clear(strs2);
+    utarray_concat(strs2, strs);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    printf("sorting strs2\n");
+    utarray_sort(strs2,strsort);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    printf("reverse sorting strs2\n");
+    utarray_sort(strs2,revsort);
+    while ( (p=(char**)utarray_next(strs2,p)) != NULL ) {
+        printf("%s ",*p);
+    }
+    printf("\n");
+    utarray_clear(strs2);
+    utarray_free(strs2);
+    utarray_free(strs);
+    return 0;
 }

+ 2 - 1
tests/test47.c

@@ -1,7 +1,8 @@
 #include <stdio.h>    /* printf */
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s,*t;
     char a[] = " text";
     utstring_new(s);

+ 15 - 12
tests/test48.c

@@ -1,20 +1,23 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *nums;
-  int i, *p;
+int main()
+{
+    UT_array *nums;
+    int i, *p;
 
-  utarray_new(nums,&ut_int_icd);
-  for(i=0; i < 10; i++) utarray_push_back(nums,&i);
+    utarray_new(nums,&ut_int_icd);
+    for(i=0; i < 10; i++) {
+        utarray_push_back(nums,&i);
+    }
 
-  for(p=(int*)utarray_front(nums);
-      p!=NULL;
-      p=(int*)utarray_next(nums,p)) {
-    printf("%d\n",*p);
-  }
+    for(p=(int*)utarray_front(nums);
+            p!=NULL;
+            p=(int*)utarray_next(nums,p)) {
+        printf("%d\n",*p);
+    }
 
-  utarray_free(nums);
+    utarray_free(nums);
 
-  return 0;
+    return 0;
 }

+ 15 - 12
tests/test49.c

@@ -1,20 +1,23 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *strs;
-  char *s, **p;
+int main()
+{
+    UT_array *strs;
+    char *s, **p;
 
-  utarray_new(strs,&ut_str_icd);
+    utarray_new(strs,&ut_str_icd);
 
-  s = "hello"; utarray_push_back(strs, &s);
-  s = "world"; utarray_push_back(strs, &s);
-  p = NULL;
-  while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
-    printf("%s\n",*p);
-  }
+    s = "hello";
+    utarray_push_back(strs, &s);
+    s = "world";
+    utarray_push_back(strs, &s);
+    p = NULL;
+    while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
+        printf("%s\n",*p);
+    }
 
-  utarray_free(strs);
+    utarray_free(strs);
 
-  return 0;
+    return 0;
 }

+ 13 - 7
tests/test5.c

@@ -9,14 +9,17 @@ typedef struct example_user_t {
     UT_hash_handle alth;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i,j;
     example_user_t *user, *tmp, *users=NULL, *altusers=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -24,11 +27,14 @@ int main(int argc,char *argv[]) {
     }
 
     /* find cookie corresponding to each even ID */
-    for(i=0;i<10;i+=2) {
+    for(i=0; i<10; i+=2) {
         j=i*i;
         HASH_FIND(alth,altusers,&j,sizeof(int),tmp);
-        if (tmp != NULL) printf("cookie %d found, user id %d\n", tmp->cookie, tmp->id);
-        else printf("cookie %d not found\n", j);
+        if (tmp != NULL) {
+            printf("cookie %d found, user id %d\n", tmp->cookie, tmp->id);
+        } else {
+            printf("cookie %d not found\n", j);
+        }
     }
-   return 0;
+    return 0;
 }

+ 16 - 11
tests/test50.c

@@ -1,18 +1,23 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *nums;
-  long l, *p;
-  UT_icd long_icd = {sizeof(long), NULL, NULL, NULL };
-  utarray_new(nums, &long_icd);
+int main()
+{
+    UT_array *nums;
+    long l, *p;
+    UT_icd long_icd = {sizeof(long), NULL, NULL, NULL };
+    utarray_new(nums, &long_icd);
 
-  l=1; utarray_push_back(nums, &l);
-  l=2; utarray_push_back(nums, &l);
+    l=1;
+    utarray_push_back(nums, &l);
+    l=2;
+    utarray_push_back(nums, &l);
 
-  p=NULL;
-  while( (p=(long*)utarray_next(nums,p)) != NULL ) printf("%ld\n", *p);
+    p=NULL;
+    while( (p=(long*)utarray_next(nums,p)) != NULL ) {
+        printf("%ld\n", *p);
+    }
 
-  utarray_free(nums);
-  return 0;
+    utarray_free(nums);
+    return 0;
 }

+ 19 - 14
tests/test51.c

@@ -6,22 +6,27 @@ typedef struct {
     int b;
 } intpair_t;
 
-int main() {
+int main()
+{
 
-  UT_array *pairs;
-  intpair_t ip, *p;
-  UT_icd intpair_icd = {sizeof(intpair_t), NULL, NULL, NULL};
-  utarray_new(pairs,&intpair_icd);
+    UT_array *pairs;
+    intpair_t ip, *p;
+    UT_icd intpair_icd = {sizeof(intpair_t), NULL, NULL, NULL};
+    utarray_new(pairs,&intpair_icd);
 
-  ip.a=1;  ip.b=2;  utarray_push_back(pairs, &ip);
-  ip.a=10; ip.b=20; utarray_push_back(pairs, &ip);
+    ip.a=1;
+    ip.b=2;
+    utarray_push_back(pairs, &ip);
+    ip.a=10;
+    ip.b=20;
+    utarray_push_back(pairs, &ip);
 
-  for(p=(intpair_t*)utarray_front(pairs);
-      p!=NULL;
-      p=(intpair_t*)utarray_next(pairs,p)) {
-    printf("%d %d\n", p->a, p->b);
-  }
+    for(p=(intpair_t*)utarray_front(pairs);
+            p!=NULL;
+            p=(intpair_t*)utarray_next(pairs,p)) {
+        printf("%d %d\n", p->a, p->b);
+    }
 
-  utarray_free(pairs);
-  return 0;
+    utarray_free(pairs);
+    return 0;
 }

+ 32 - 23
tests/test52.c

@@ -7,32 +7,41 @@ typedef struct {
     char *s;
 } intchar_t;
 
-static void intchar_copy(void *_dst, const void *_src) {
-  intchar_t *dst = (intchar_t*)_dst, *src = (intchar_t*)_src;
-  dst->a = src->a;
-  dst->s = (src->s != NULL) ? strdup(src->s) : NULL;
+static void intchar_copy(void *_dst, const void *_src)
+{
+    intchar_t *dst = (intchar_t*)_dst, *src = (intchar_t*)_src;
+    dst->a = src->a;
+    dst->s = (src->s != NULL) ? strdup(src->s) : NULL;
 }
 
-static void intchar_dtor(void *_elt) {
-  intchar_t *elt = (intchar_t*)_elt;
-  if (elt->s != NULL) free(elt->s);
+static void intchar_dtor(void *_elt)
+{
+    intchar_t *elt = (intchar_t*)_elt;
+    if (elt->s != NULL) {
+        free(elt->s);
+    }
 }
 
-int main() {
-  UT_array *intchars;
-  intchar_t ic, *p;
-  UT_icd intchar_icd = {sizeof(intchar_t), NULL, intchar_copy, intchar_dtor};
-  utarray_new(intchars, &intchar_icd);
-
-  ic.a=1; ic.s="hello"; utarray_push_back(intchars, &ic);
-  ic.a=2; ic.s="world"; utarray_push_back(intchars, &ic);
-
-  p=NULL;
-  while( (p=(intchar_t*)utarray_next(intchars,p)) != NULL ) {
-    printf("%d %s\n", p->a, (p->s != NULL) ? p->s : "null");
-  }
-
-  utarray_free(intchars);
-  return 0;
+int main()
+{
+    UT_array *intchars;
+    intchar_t ic, *p;
+    UT_icd intchar_icd = {sizeof(intchar_t), NULL, intchar_copy, intchar_dtor};
+    utarray_new(intchars, &intchar_icd);
+
+    ic.a=1;
+    ic.s="hello";
+    utarray_push_back(intchars, &ic);
+    ic.a=2;
+    ic.s="world";
+    utarray_push_back(intchars, &ic);
+
+    p=NULL;
+    while( (p=(intchar_t*)utarray_next(intchars,p)) != NULL ) {
+        printf("%d %s\n", p->a, (p->s != NULL) ? p->s : "null");
+    }
+
+    utarray_free(intchars);
+    return 0;
 }
 

+ 2 - 1
tests/test53.c

@@ -1,7 +1,8 @@
 #include <stdio.h>
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s;
 
     utstring_new(s);

+ 2 - 1
tests/test54.c

@@ -1,7 +1,8 @@
 #include <stdio.h>
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s, *t;
 
     utstring_new(s);

+ 2 - 1
tests/test55.c

@@ -1,7 +1,8 @@
 #include <stdio.h>
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s;
     char binary[] = "\xff\xff";
 

+ 18 - 8
tests/test56.c

@@ -18,13 +18,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-static int namecmp(void *_a, void *_b) {
+static int namecmp(void *_a, void *_b)
+{
     el *a = (el*)_a;
     el *b = (el*)_b;
     return strcmp(a->bname,b->bname);
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     el *name, *elt, *tmp, etmp;
     int i;
     example_user_t *user, *users=NULL;
@@ -44,28 +46,36 @@ int main(int argc, char *argv[]) {
 
     while (fgets(linebuf,BUFLEN,file) != NULL) {
         name = (el*)malloc(sizeof(el));
-        if (name == NULL) exit(-1);
+        if (name == NULL) {
+            exit(-1);
+        }
         strncpy(name->bname,linebuf,sizeof(name->bname));
         DL_APPEND(head, name);
     }
     DL_SORT(head, namecmp);
-    DL_FOREACH(head,elt) printf("%s", elt->bname);
+    DL_FOREACH(head,elt) {
+        printf("%s", elt->bname);
+    }
 
     memcpy(etmp.bname, "WES\n", 5UL);
     DL_SEARCH(head,elt,&etmp,namecmp);
-    if (elt != NULL) printf("found %s\n", elt->bname);
+    if (elt != NULL) {
+        printf("found %s\n", elt->bname);
+    }
 
     /* now delete each element, use the safe iterator */
     DL_FOREACH_SAFE(head,elt,tmp) {
-      DL_DELETE(head,elt);
+        DL_DELETE(head,elt);
     }
 
     fclose(file);
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);

+ 23 - 18
tests/test57.c

@@ -3,25 +3,30 @@
 #include "uthash.h"
 
 typedef struct {
-  void *key;
-  int i;
-  UT_hash_handle hh;
+    void *key;
+    int i;
+    UT_hash_handle hh;
 } el_t;
 
-int main() {
-  el_t *d;
-  el_t *hash = NULL;
-  char *someaddr = NULL;
-  el_t *e = (el_t*)malloc(sizeof(el_t));
-  if (!e) return -1;
-  e->key = (void*)someaddr;
-  e->i = 1;
-  HASH_ADD_PTR(hash,key,e);
-  HASH_FIND_PTR(hash, &someaddr, d);
-  if (d != NULL) printf("found\n");
+int main()
+{
+    el_t *d;
+    el_t *hash = NULL;
+    char *someaddr = NULL;
+    el_t *e = (el_t*)malloc(sizeof(el_t));
+    if (!e) {
+        return -1;
+    }
+    e->key = (void*)someaddr;
+    e->i = 1;
+    HASH_ADD_PTR(hash,key,e);
+    HASH_FIND_PTR(hash, &someaddr, d);
+    if (d != NULL) {
+        printf("found\n");
+    }
 
-  /* release memory */
-  HASH_DEL(hash,e);
-  free(e);
-  return 0;
+    /* release memory */
+    HASH_DEL(hash,e);
+    free(e);
+    return 0;
 }

+ 10 - 6
tests/test58.c

@@ -8,15 +8,17 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     unsigned c;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
-        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL)
-           exit(-1);
+    for(i=0; i<10; i++) {
+        if ( (user = (example_user_t*)malloc(sizeof(example_user_t))) == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -31,7 +33,9 @@ int main(int argc,char *argv[]) {
     printf("%u users. Deleting odd id's...\n", c);
     /* delete the odd id's */
     HASH_ITER(hh, users, user, tmp) {
-        if ((user->id & 1) != 0) HASH_DEL(users,user);
+        if ((user->id & 1) != 0) {
+            HASH_DEL(users,user);
+        }
     }
 
     /* show the hash */
@@ -52,5 +56,5 @@ int main(int argc,char *argv[]) {
     for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {
         printf("user %d, cookie %d\n", user->id, user->cookie);
     }
-   return 0;
+    return 0;
 }

+ 40 - 35
tests/test59.c

@@ -5,48 +5,53 @@
 
 /* hash of hashes */
 typedef struct item {
-  char name[10];
-  struct item *sub;
-  int val;
-  UT_hash_handle hh;
+    char name[10];
+    struct item *sub;
+    int val;
+    UT_hash_handle hh;
 } item_t;
 
-int main(int argc, char *argvp[]) {
-  item_t *item1, *item2, *tmp1, *tmp2;
-  item_t *items=NULL;
+int main(int argc, char *argvp[])
+{
+    item_t *item1, *item2, *tmp1, *tmp2;
+    item_t *items=NULL;
 
-  /* make initial element */
-  item_t *i = malloc(sizeof(*i));
-  if (i == NULL) exit(-1);
-  strcpy(i->name, "bob");
-  i->sub = NULL;
-  i->val = 0;
-  HASH_ADD_STR(items, name, i);
+    /* make initial element */
+    item_t *i = malloc(sizeof(*i));
+    if (i == NULL) {
+        exit(-1);
+    }
+    strcpy(i->name, "bob");
+    i->sub = NULL;
+    i->val = 0;
+    HASH_ADD_STR(items, name, i);
 
-  /* add a sub hash table off this element */
-  item_t *s = malloc(sizeof(*s));
-  if (s == NULL) exit(-1);
-  strcpy(s->name, "age");
-  s->sub = NULL;
-  s->val = 37;
-  HASH_ADD_STR(i->sub, name, s);
+    /* add a sub hash table off this element */
+    item_t *s = malloc(sizeof(*s));
+    if (s == NULL) {
+        exit(-1);
+    }
+    strcpy(s->name, "age");
+    s->sub = NULL;
+    s->val = 37;
+    HASH_ADD_STR(i->sub, name, s);
 
-  /* iterate over hash elements  */
-  HASH_ITER(hh, items, item1, tmp1) {
-    HASH_ITER(hh, item1->sub, item2, tmp2) {
-      printf("$items{%s}{%s} = %d\n", item1->name, item2->name, item2->val);
+    /* iterate over hash elements  */
+    HASH_ITER(hh, items, item1, tmp1) {
+        HASH_ITER(hh, item1->sub, item2, tmp2) {
+            printf("$items{%s}{%s} = %d\n", item1->name, item2->name, item2->val);
+        }
     }
-  }
 
-  /* clean up both hash tables */
-  HASH_ITER(hh, items, item1, tmp1) {
-    HASH_ITER(hh, item1->sub, item2, tmp2) {
-      HASH_DEL(item1->sub, item2);
-      free(item2);
+    /* clean up both hash tables */
+    HASH_ITER(hh, items, item1, tmp1) {
+        HASH_ITER(hh, item1->sub, item2, tmp2) {
+            HASH_DEL(item1->sub, item2);
+            free(item2);
+        }
+        HASH_DEL(items, item1);
+        free(item1);
     }
-    HASH_DEL(items, item1);
-    free(item1);
-  }
 
-  return 0;
+    return 0;
 }

+ 18 - 9
tests/test6.c

@@ -14,40 +14,49 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-static void *alt_malloc(size_t sz) {
-    if (sz == sizeof(UT_hash_table)) printf("%s\n", "alt malloc table");
+static void *alt_malloc(size_t sz)
+{
+    if (sz == sizeof(UT_hash_table)) {
+        printf("%s\n", "alt malloc table");
+    }
     return malloc(sz);
 }
-static void alt_free(void *ptr) {
+static void alt_free(void *ptr)
+{
     /* printf("%s\n", "alt_free"); */
     free(ptr);
 }
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     /* delete each ID */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         HASH_FIND_INT(users,&i,tmp);
         if (tmp != NULL) {
             HASH_DEL(users,tmp);
             free(tmp);
-        } else printf("user id %d not found\n", i);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
 
     /* show the hash */
     for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {
         printf("user %d, cookie %d\n", user->id, user->cookie);
     }
-   return 0;
+    return 0;
 }

+ 36 - 31
tests/test60.c

@@ -5,42 +5,47 @@
 
 /* hash of hashes */
 typedef struct item {
-  char name[10];
-  struct item *sub;
-  int val;
-  UT_hash_handle hh;
+    char name[10];
+    struct item *sub;
+    int val;
+    UT_hash_handle hh;
 } item_t;
 
-int main(int argc, char *argvp[]) {
-  item_t *item1, *item2, *tmp1, *tmp2;
-  item_t *items=NULL;
+int main(int argc, char *argvp[])
+{
+    item_t *item1, *item2, *tmp1, *tmp2;
+    item_t *items=NULL;
 
-  /* make initial element */
-  item_t *i = malloc(sizeof(*i));
-  if (i == NULL) exit(-1);
-  strcpy(i->name, "bob");
-  i->sub = NULL;
-  i->val = 0;
-  HASH_ADD_STR(items, name, i);
+    /* make initial element */
+    item_t *i = malloc(sizeof(*i));
+    if (i == NULL) {
+        exit(-1);
+    }
+    strcpy(i->name, "bob");
+    i->sub = NULL;
+    i->val = 0;
+    HASH_ADD_STR(items, name, i);
 
-  /* add a sub hash table off this element */
-  item_t *s = malloc(sizeof(*s));
-  if (s == NULL) exit(-1);
-  strcpy(s->name, "age");
-  s->sub = NULL;
-  s->val = 37;
-  HASH_ADD_STR(i->sub, name, s);
+    /* add a sub hash table off this element */
+    item_t *s = malloc(sizeof(*s));
+    if (s == NULL) {
+        exit(-1);
+    }
+    strcpy(s->name, "age");
+    s->sub = NULL;
+    s->val = 37;
+    HASH_ADD_STR(i->sub, name, s);
 
-  /* iterate over hash elements, printing and freeing them */
-  HASH_ITER(hh, items, item1, tmp1) {
-    HASH_ITER(hh, item1->sub, item2, tmp2) {
-      printf("$items{%s}{%s} = %d\n", item1->name, item2->name, item2->val);
-      HASH_DEL(item1->sub, item2);
-      free(item2);
+    /* iterate over hash elements, printing and freeing them */
+    HASH_ITER(hh, items, item1, tmp1) {
+        HASH_ITER(hh, item1->sub, item2, tmp2) {
+            printf("$items{%s}{%s} = %d\n", item1->name, item2->name, item2->val);
+            HASH_DEL(item1->sub, item2);
+            free(item2);
+        }
+        HASH_DEL(items, item1);
+        free(item1);
     }
-    HASH_DEL(items, item1);
-    free(item1);
-  }
 
-  return 0;
+    return 0;
 }

+ 43 - 36
tests/test61.c

@@ -1,42 +1,49 @@
 #include <stdio.h>
 #include "utarray.h"
 
-static int strsort(const void *_a, const void *_b) {
-  char *a = *(char**)_a;
-  char *b = *(char**)_b;
-  return strcmp(a,b);
+static int strsort(const void *_a, const void *_b)
+{
+    char *a = *(char**)_a;
+    char *b = *(char**)_b;
+    return strcmp(a,b);
 }
 
-int main() {
-  UT_array *strs;
-  char *s, **p;
-
-  utarray_new(strs,&ut_str_icd);
-
-  s = "hello"; utarray_push_back(strs, &s);
-  s = "world"; utarray_push_back(strs, &s);
-  s = "one"; utarray_push_back(strs, &s);
-  s = "two"; utarray_push_back(strs, &s);
-  s = "three"; utarray_push_back(strs, &s);
-
-  p = NULL;
-  while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
-    s = *p;
-    printf("%s\n",s);
-  }
-
-  printf("sorting\n");
-  utarray_sort(strs,strsort);
-
-  p = NULL;
-  while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
-    s = *p;
-    printf("finding %s\n",s);
-    p = utarray_find(strs,&s,strsort);
-    printf(" %s\n", (p != NULL) ? (*p) : "failed");
-  }
-
-  utarray_free(strs);
-
-  return 0;
+int main()
+{
+    UT_array *strs;
+    char *s, **p;
+
+    utarray_new(strs,&ut_str_icd);
+
+    s = "hello";
+    utarray_push_back(strs, &s);
+    s = "world";
+    utarray_push_back(strs, &s);
+    s = "one";
+    utarray_push_back(strs, &s);
+    s = "two";
+    utarray_push_back(strs, &s);
+    s = "three";
+    utarray_push_back(strs, &s);
+
+    p = NULL;
+    while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
+        s = *p;
+        printf("%s\n",s);
+    }
+
+    printf("sorting\n");
+    utarray_sort(strs,strsort);
+
+    p = NULL;
+    while ( (p=(char**)utarray_next(strs,p)) != NULL ) {
+        s = *p;
+        printf("finding %s\n",s);
+        p = utarray_find(strs,&s,strsort);
+        printf(" %s\n", (p != NULL) ? (*p) : "failed");
+    }
+
+    utarray_free(strs);
+
+    return 0;
 }

+ 75 - 48
tests/test62.c

@@ -9,55 +9,82 @@
 #define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL)
 
 #define yn(rc) ((rc!=0U)?"y":"n")
-int main(int argc,char*argv[]) {
-  unsigned rc;
-  char *c = malloc(8UL);
-  if (c == NULL) exit(-1);
-  *(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;
-
-  /* ---------------------------------------- */
-  /* test whether alignment is detected properly */
-
-  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");
-
-  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");
-
-  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");
-
-  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");
-
-  /* ---------------------------------------- */
-  /* test careful reassembly of an unaligned integer */
+int main(int argc,char*argv[])
+{
+    unsigned rc;
+    char *c = malloc(8UL);
+    if (c == NULL) {
+        exit(-1);
+    }
+    *(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;
+
+    /* ---------------------------------------- */
+    /* test whether alignment is detected properly */
+
+    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");
+
+    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");
+
+    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");
+
+    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");
+
+    /* ---------------------------------------- */
+    /* 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);
+    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
 
-  free(c);
-  return 0;
+    free(c);
+    return 0;
 }

+ 29 - 9
tests/test63.c

@@ -6,42 +6,62 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[10], *e;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test LL macros */
     printf("LL macros\n");
     LL_APPEND(headA,&els[0]);
     LL_APPEND(headA,&els[1]);
     LL_APPEND(headA,&els[2]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     LL_APPEND(headB,&els[3]);
     LL_APPEND(headB,&els[4]);
     LL_APPEND(headB,&els[5]);
-    LL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     LL_CONCAT(headA,headB);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* other variations */
     headA = NULL;
     LL_CONCAT(headA,headB);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     headB = NULL;
     LL_CONCAT(headA,headB);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
-
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     headA=NULL;
     headB=NULL;
     LL_APPEND(headA,&els[0]);
     LL_APPEND(headB,&els[1]);
     LL_CONCAT(headA,headB);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 29 - 9
tests/test64.c

@@ -6,42 +6,62 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[10], *e;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test DL macros */
     printf("DL macros\n");
     DL_APPEND(headA,&els[0]);
     DL_APPEND(headA,&els[1]);
     DL_APPEND(headA,&els[2]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     DL_APPEND(headB,&els[3]);
     DL_APPEND(headB,&els[4]);
     DL_APPEND(headB,&els[5]);
-    DL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     DL_CONCAT(headA,headB);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* other variations */
     headA = NULL;
     DL_CONCAT(headA,headB);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     headB = NULL;
     DL_CONCAT(headA,headB);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
-
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     headA=NULL;
     headB=NULL;
     DL_APPEND(headA,&els[0]);
     DL_APPEND(headB,&els[1]);
     DL_CONCAT(headA,headB);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 19 - 16
tests/test65.c

@@ -33,7 +33,9 @@ static void add_to_cache(const char *key, const char *value)
 {
     struct CacheEntry *entry, *tmp_entry;
     entry = malloc(sizeof(struct CacheEntry));
-    if (entry == NULL) exit(-1);
+    if (entry == NULL) {
+        exit(-1);
+    }
     entry->key = strdup(key);
     entry->value = strdup(value);
     HASH_ADD_KEYPTR(hh, cache, entry->key, strlen(entry->key), entry);
@@ -53,22 +55,23 @@ static void add_to_cache(const char *key, const char *value)
 }
 
 /* main added by Troy D. Hanson */
-int main(int argc, char *argv[]) {
-  char linebuf[100], nbuf[10];
-  FILE *file;
-  int i=0;
+int main(int argc, char *argv[])
+{
+    char linebuf[100], nbuf[10];
+    FILE *file;
+    int i=0;
 
-  file = fopen( "test65.dat", "r" );
-  if (file == NULL) {
-      perror("can't open: ");
-      exit(-1);
-  }
+    file = fopen( "test65.dat", "r" );
+    if (file == NULL) {
+        perror("can't open: ");
+        exit(-1);
+    }
 
-  while (fgets(linebuf,sizeof(linebuf),file) != NULL) {
-    snprintf(nbuf,sizeof(nbuf),"%u",i++);
-    add_to_cache(linebuf, nbuf);
-  }
+    while (fgets(linebuf,sizeof(linebuf),file) != NULL) {
+        snprintf(nbuf,sizeof(nbuf),"%u",i++);
+        add_to_cache(linebuf, nbuf);
+    }
 
-  fclose(file);
-  return 0;
+    fclose(file);
+    return 0;
 }

+ 11 - 6
tests/test66.c

@@ -8,16 +8,20 @@ typedef struct person_t {
     UT_hash_handle hh;
 } person_t;
 
-int main(int argc, char*argv[]) {
+int main(int argc, char*argv[])
+{
     person_t *people=NULL, *person;
     const char **name;
     const char * names[] = { "bob", "jack", "gary", "ty", "bo", "phil", "art",
-                      "gil", "buck", "ted", NULL };
+                             "gil", "buck", "ted", NULL
+                           };
     int id=0;
 
     for(name=names; *name!=NULL; name++) {
         person = (person_t*)malloc(sizeof(person_t));
-        if (person == NULL) exit(-1);
+        if (person == NULL) {
+            exit(-1);
+        }
         strncpy(person->first_name, *name,sizeof(person->first_name));
         person->id = id++;
         HASH_ADD_STR(people,first_name,person);
@@ -29,10 +33,11 @@ int main(int argc, char*argv[]) {
 
     for(name=names; *name!=NULL; name++) {
         HASH_FIND_STR(people,*name,*p);
-        if (person != NULL)
+        if (person != NULL) {
             printf("found %s (id %d)\n", person->first_name, person->id);
-        else
+        } else {
             printf("failed to find %s\n", *name);
+        }
     }
-   return 0;
+    return 0;
 }

+ 20 - 17
tests/test67.c

@@ -1,27 +1,30 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *nums;
-  int i, *p;
+int main()
+{
+    UT_array *nums;
+    int i, *p;
 
-  utarray_new(nums,&ut_int_icd);
-  for(i=0; i < 10; i++) utarray_push_back(nums,&i);
+    utarray_new(nums,&ut_int_icd);
+    for(i=0; i < 10; i++) {
+        utarray_push_back(nums,&i);
+    }
 
-  for(p=(int*)utarray_back(nums);
-      p!=NULL;
-      p=(int*)utarray_prev(nums,p)) {
-    printf("%d\n",*p);
-  }
+    for(p=(int*)utarray_back(nums);
+            p!=NULL;
+            p=(int*)utarray_prev(nums,p)) {
+        printf("%d\n",*p);
+    }
 
-  /* the other form of iteration starting from NULL (back) */
-  p=NULL;
-  while ( (p=(int*)utarray_prev(nums,p)) != NULL ) {
-    printf("%d\n",*p);
-  }
+    /* the other form of iteration starting from NULL (back) */
+    p=NULL;
+    while ( (p=(int*)utarray_prev(nums,p)) != NULL ) {
+        printf("%d\n",*p);
+    }
 
 
-  utarray_free(nums);
+    utarray_free(nums);
 
-  return 0;
+    return 0;
 }

+ 41 - 11
tests/test68.c

@@ -7,12 +7,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[20], *e, *tmp;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<20;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<20; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test DL macros */
     printf("DL replace elem\n");
@@ -20,24 +23,42 @@ int main(int argc, char *argv[]) {
     DL_APPEND(headA,&els[1]);
     DL_APPEND(headA,&els[2]);
     DL_APPEND(headA,&els[3]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace head elem */
     DL_REPLACE_ELEM(headA, &els[0], &els[4]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_REPLACE_ELEM(headA, &els[4], &els[5]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace last elem */
     DL_REPLACE_ELEM(headA, &els[3], &els[6]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_REPLACE_ELEM(headA, &els[6], &els[7]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace middle elem */
     DL_REPLACE_ELEM(headA, &els[1], &els[8]);
     DL_REPLACE_ELEM(headA, &els[2], &els[9]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace all just to be sure the list is intact... */
     i = 10;
@@ -45,13 +66,22 @@ int main(int argc, char *argv[]) {
         DL_REPLACE_ELEM(headA, e, &els[i]);
         i++;
     }
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* single elem */
     DL_APPEND(headB, &els[18]);
-    DL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_REPLACE_ELEM(headB, &els[18], &els[19]);
-    DL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 45 - 12
tests/test69.c

@@ -7,12 +7,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[26], *e, *tmp;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<25;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<25; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test DL macros */
     printf("DL prepend elem\n");
@@ -20,24 +23,42 @@ int main(int argc, char *argv[]) {
     DL_APPEND(headA,&els[1]);
     DL_APPEND(headA,&els[2]);
     DL_APPEND(headA,&els[3]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend head elem */
     DL_PREPEND_ELEM(headA, &els[0], &els[4]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_PREPEND_ELEM(headA, &els[4], &els[5]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend last elem */
     DL_PREPEND_ELEM(headA, &els[3], &els[6]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_PREPEND_ELEM(headA, &els[6], &els[7]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend middle elem */
     DL_PREPEND_ELEM(headA, &els[2], &els[8]);
     DL_PREPEND_ELEM(headA, &els[2], &els[9]);
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend all just to be sure the list is intact... */
     i = 10;
@@ -45,15 +66,27 @@ int main(int argc, char *argv[]) {
         DL_PREPEND_ELEM(headA, e, &els[i]);
         i++;
     }
-    DL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* single elem */
     DL_APPEND(headB, &els[20]);
-    DL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_PREPEND_ELEM(headB, &els[20], &els[21]);
-    DL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     DL_PREPEND_ELEM(headB, &els[21], &els[22]);
-    DL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    DL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 11 - 6
tests/test7.c

@@ -9,31 +9,36 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<1000;i++) {
+    for(i=0; i<1000; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     /* delete each ID */
-    for(i=0;i<1000;i++) {
+    for(i=0; i<1000; i++) {
         HASH_FIND_INT(users,&i,tmp);
         if (tmp != NULL) {
             HASH_DEL(users,tmp);
             free(tmp);
-        } else printf("user id %d not found\n", i);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
 
     /* show the hash */
     for(user=users; user != NULL; user=(example_user_t*)(user->hh.next)) {
         printf("user %d, cookie %d\n", user->id, user->cookie);
     }
-   return 0;
+    return 0;
 }

+ 41 - 11
tests/test70.c

@@ -7,12 +7,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[20], *e, *tmp;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<20;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<20; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test LL macros */
     printf("LL replace elem\n");
@@ -20,24 +23,42 @@ int main(int argc, char *argv[]) {
     LL_APPEND(headA,&els[1]);
     LL_APPEND(headA,&els[2]);
     LL_APPEND(headA,&els[3]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace head elem */
     LL_REPLACE_ELEM(headA, &els[0], &els[4]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_REPLACE_ELEM(headA, &els[4], &els[5]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace last elem */
     LL_REPLACE_ELEM(headA, &els[3], &els[6]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_REPLACE_ELEM(headA, &els[6], &els[7]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace middle elem */
     LL_REPLACE_ELEM(headA, &els[1], &els[8]);
     LL_REPLACE_ELEM(headA, &els[2], &els[9]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace all just to be sure the list is intact... */
     i = 10;
@@ -45,13 +66,22 @@ int main(int argc, char *argv[]) {
         LL_REPLACE_ELEM(headA, e, &els[i]);
         i++;
     }
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* single elem */
     LL_APPEND(headB, &els[18]);
-    LL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_REPLACE_ELEM(headB, &els[18], &els[19]);
-    LL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 45 - 12
tests/test71.c

@@ -7,12 +7,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[26], *e, *tmp;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<25;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<25; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test LL macros */
     printf("LL prepend elem\n");
@@ -20,24 +23,42 @@ int main(int argc, char *argv[]) {
     LL_APPEND(headA,&els[1]);
     LL_APPEND(headA,&els[2]);
     LL_APPEND(headA,&els[3]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend head elem */
     LL_PREPEND_ELEM(headA, &els[0], &els[4]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_PREPEND_ELEM(headA, &els[4], &els[5]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend last elem */
     LL_PREPEND_ELEM(headA, &els[3], &els[6]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_PREPEND_ELEM(headA, &els[6], &els[7]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend middle elem */
     LL_PREPEND_ELEM(headA, &els[2], &els[8]);
     LL_PREPEND_ELEM(headA, &els[2], &els[9]);
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend all just to be sure the list is intact... */
     i = 10;
@@ -45,15 +66,27 @@ int main(int argc, char *argv[]) {
         LL_PREPEND_ELEM(headA, e, &els[i]);
         i++;
     }
-    LL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* single elem */
     LL_APPEND(headB, &els[20]);
-    LL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_PREPEND_ELEM(headB, &els[20], &els[21]);
-    LL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     LL_PREPEND_ELEM(headB, &els[21], &els[22]);
-    LL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    LL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 41 - 11
tests/test72.c

@@ -7,12 +7,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[20], *e, *tmp, *tmp2;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<20;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<20; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL replace elem\n");
@@ -20,24 +23,42 @@ int main(int argc, char *argv[]) {
     CDL_PREPEND(headA,&els[2]);
     CDL_PREPEND(headA,&els[1]);
     CDL_PREPEND(headA,&els[0]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace head elem */
     CDL_REPLACE_ELEM(headA, &els[0], &els[4]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_REPLACE_ELEM(headA, &els[4], &els[5]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace last elem */
     CDL_REPLACE_ELEM(headA, &els[3], &els[6]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_REPLACE_ELEM(headA, &els[6], &els[7]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace middle elem */
     CDL_REPLACE_ELEM(headA, &els[1], &els[8]);
     CDL_REPLACE_ELEM(headA, &els[2], &els[9]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* replace all just to be sure the list is intact... */
     i = 10;
@@ -45,13 +66,22 @@ int main(int argc, char *argv[]) {
         CDL_REPLACE_ELEM(headA, e, &els[i]);
         i++;
     }
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* single elem */
     CDL_PREPEND(headB, &els[18]);
-    CDL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_REPLACE_ELEM(headB, &els[18], &els[19]);
-    CDL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 45 - 12
tests/test73.c

@@ -7,12 +7,15 @@ typedef struct el {
     struct el *next, *prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[26], *e, *tmp, *tmp2;
     el *headA = NULL;
     el *headB = NULL;
-    for(i=0;i<25;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<25; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL prepend elem\n");
@@ -20,24 +23,42 @@ int main(int argc, char *argv[]) {
     CDL_PREPEND(headA,&els[2]);
     CDL_PREPEND(headA,&els[1]);
     CDL_PREPEND(headA,&els[0]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend head elem */
     CDL_PREPEND_ELEM(headA, &els[0], &els[4]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_PREPEND_ELEM(headA, &els[4], &els[5]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend last elem */
     CDL_PREPEND_ELEM(headA, &els[3], &els[6]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_PREPEND_ELEM(headA, &els[6], &els[7]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend middle elem */
     CDL_PREPEND_ELEM(headA, &els[2], &els[8]);
     CDL_PREPEND_ELEM(headA, &els[2], &els[9]);
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* prepend all just to be sure the list is intact... */
     i = 10;
@@ -45,15 +66,27 @@ int main(int argc, char *argv[]) {
         CDL_PREPEND_ELEM(headA, e, &els[i]);
         i++;
     }
-    CDL_FOREACH(headA,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headA,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     /* single elem */
     CDL_PREPEND(headB, &els[20]);
-    CDL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_PREPEND_ELEM(headB, &els[20], &els[21]);
-    CDL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
     CDL_PREPEND_ELEM(headB, &els[21], &els[22]);
-    CDL_FOREACH(headB,e) printf("%c ", e->id); printf("\n");
+    CDL_FOREACH(headB,e) {
+        printf("%c ", e->id);
+    }
+    printf("\n");
 
     return 0;
 }

+ 7 - 8
tests/test74.c

@@ -1,7 +1,8 @@
 #include <stdio.h>    /* printf */
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s,*t;
     char V_TestStr[] = "There are two needle\0s in this \0haystack with needle\0s.";
     char V_NeedleStr[] = "needle\0s";
@@ -19,15 +20,13 @@ int main() {
 
     V_FindCnt = 0;
     V_FindPos = 0;
-    do
-    {
-        V_FindPos = utstring_find(s, 
-                                  V_FindPos, 
-                                  utstring_body(t), 
+    do {
+        V_FindPos = utstring_find(s,
+                                  V_FindPos,
+                                  utstring_body(t),
                                   utstring_len(t));
         printf("utstring_find()=%ld\n", V_FindPos);
-        if (V_FindPos >= 0)
-        {
+        if (V_FindPos >= 0) {
             V_FindPos++;
             V_FindCnt++;
         }

+ 7 - 8
tests/test75.c

@@ -1,7 +1,8 @@
 #include <stdio.h>    /* printf */
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s,*t;
     char V_TestStr[] = "There are two needle\0s in this \0haystack with needle\0s.";
     char V_NeedleStr[] = "needle\0s";
@@ -19,15 +20,13 @@ int main() {
 
     V_FindCnt = 0;
     V_FindPos = -1;
-    do
-    {
-        V_FindPos = utstring_findR(s, 
-                                   V_FindPos, 
-                                   utstring_body(t), 
+    do {
+        V_FindPos = utstring_findR(s,
+                                   V_FindPos,
+                                   utstring_body(t),
                                    utstring_len(t));
         printf("utstring_findR()=%ld\n", V_FindPos);
-        if (V_FindPos >= 0)
-        {
+        if (V_FindPos >= 0) {
             V_FindPos--;
             V_FindCnt++;
         }

+ 10 - 14
tests/test76.c

@@ -1,7 +1,8 @@
 #include <stdio.h>    /* printf */
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s,*t;
     char V_TestStr[] = "There are two needle\0s in this \0haystack with needle\0s.";
     char V_NeedleStr[] = "needle\0s";
@@ -20,22 +21,19 @@ int main() {
     printf("\"%s\" len=%u\n", utstring_body(t), utstring_len(t));
 
     V_KMP_Table = (long *)malloc(sizeof(long) * (utstring_len(t) + 1));
-    if (V_KMP_Table != NULL)
-    {
+    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, 
-                                       utstring_body(t), 
-                                       utstring_len(t), 
+        do {
+            V_FindPos = _utstring_find(utstring_body(s) + V_StartPos,
+                                       utstring_len(s) - V_StartPos,
+                                       utstring_body(t),
+                                       utstring_len(t),
                                        V_KMP_Table);
-            if (V_FindPos >= 0)
-            {
+            if (V_FindPos >= 0) {
                 V_FindPos += V_StartPos;
                 V_FindCnt++;
                 V_StartPos = V_FindPos + 1;
@@ -45,9 +43,7 @@ int main() {
         printf("FindCnt=%u\n", (unsigned)V_FindCnt);
 
         free(V_KMP_Table);
-    }
-    else
-    {
+    } else {
         printf("malloc() failed...\n");
     }
 

+ 25 - 22
tests/test77.c

@@ -1,7 +1,8 @@
 #include <stdio.h>    /* printf */
 #include "utstring.h"
 
-int main() {
+int main()
+{
     UT_string *s,*t;
     char V_TestStr[] = "There are two needle\0s in this \0haystack with needle\0s.";
     char V_NeedleStr[] = "needle\0s";
@@ -20,22 +21,19 @@ int main() {
     printf("\"%s\" len=%u\n", utstring_body(t), utstring_len(t));
 
     V_KMP_Table = (long *)malloc(sizeof(long) * (utstring_len(t) + 1));
-    if (V_KMP_Table != NULL)
-    {
+    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), 
-                                        V_StartPos + 1, 
-                                        utstring_body(t), 
-                                        utstring_len(t), 
+        do {
+            V_FindPos = _utstring_findR(utstring_body(s),
+                                        V_StartPos + 1,
+                                        utstring_body(t),
+                                        utstring_len(t),
                                         V_KMP_Table);
-            if (V_FindPos >= 0)
-            {
+            if (V_FindPos >= 0) {
                 V_FindCnt++;
                 V_StartPos = V_FindPos - 1;
             }
@@ -44,9 +42,7 @@ int main() {
         printf("FindCnt=%u\n", (unsigned)V_FindCnt);
 
         free(V_KMP_Table);
-    }
-    else
-    {
+    } else {
         printf("malloc() failed...\n");
     }
 
@@ -55,14 +51,21 @@ int main() {
     utstring_printf(s,"ABC ABCDAB ABCDABCDABDE");
     int o;
 
-    o=utstring_find(  s, -9, "ABC", 3 ) ; printf("expect 15 %d\n",o);
-    o=utstring_find(  s,  3, "ABC", 3 ) ; printf("expect  4 %d\n",o);
-    o=utstring_find(  s, 16, "ABC", 3 ) ; printf("expect -1 %d\n",o);
-    o=utstring_findR( s, -9, "ABC", 3 ) ; printf("expect 11 %d\n",o);
-    o=utstring_findR( s, 12, "ABC", 3 ) ; printf("expect  4 %d\n",o);
-    o=utstring_findR( s, 13, "ABC", 3 ) ; printf("expect 11 %d\n",o);
-    o=utstring_findR( s,  2, "ABC", 3 ) ; printf("expect  0 %d\n",o);
-    
+    o=utstring_find(  s, -9, "ABC", 3 ) ;
+    printf("expect 15 %d\n",o);
+    o=utstring_find(  s,  3, "ABC", 3 ) ;
+    printf("expect  4 %d\n",o);
+    o=utstring_find(  s, 16, "ABC", 3 ) ;
+    printf("expect -1 %d\n",o);
+    o=utstring_findR( s, -9, "ABC", 3 ) ;
+    printf("expect 11 %d\n",o);
+    o=utstring_findR( s, 12, "ABC", 3 ) ;
+    printf("expect  4 %d\n",o);
+    o=utstring_findR( s, 13, "ABC", 3 ) ;
+    printf("expect 11 %d\n",o);
+    o=utstring_findR( s,  2, "ABC", 3 ) ;
+    printf("expect  0 %d\n",o);
+
 
 
     utstring_free(s);

+ 36 - 17
tests/test78.c

@@ -6,51 +6,62 @@ typedef struct el {
     struct el *Next, *Prev;
 } el;
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
     int i;
     el els[10], *e;
     el *head = NULL;
-    for(i=0;i<10;i++) els[i].id=(int)'a'+i;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
 
     /* test CDL macros */
     printf("CDL macros\n");
     CDL_PREPEND2(head,&els[0],Prev,Next);
     CDL_PREPEND2(head,&els[1],Prev,Next);
     CDL_PREPEND2(head,&els[2],Prev,Next);
-    CDL_FOREACH2(head,e,Next)
+    CDL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* point head to head->next */
     printf("advancing head pointer\n");
     head = head->Next;
-    CDL_FOREACH2(head,e,Next)
+    CDL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->Next)
+    for(i=0,e=head; e && i<10; i++,e=e->Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* follow circular loop backwards a few times */
-    for(i=0,e=head;e && i<10;i++,e=e->Prev)
+    for(i=0,e=head; e && i<10; i++,e=e->Prev) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting b\n");
     CDL_DELETE2(head,&els[1],Prev,Next);
-    CDL_FOREACH2(head,e,Next) printf("%c ", e->id);
+    CDL_FOREACH2(head,e,Next) {
+        printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (a)\n");
     CDL_DELETE2(head,&els[0],Prev,Next);
-    CDL_FOREACH2(head,e,Next)
+    CDL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
     printf("deleting (c)\n");
     CDL_DELETE2(head,&els[2],Prev,Next);
-    CDL_FOREACH2(head,e,Next)
+    CDL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test DL macros */
@@ -58,26 +69,30 @@ int main(int argc, char *argv[]) {
     DL_APPEND2(head,&els[0],Prev,Next);
     DL_APPEND2(head,&els[1],Prev,Next);
     DL_APPEND2(head,&els[2],Prev,Next);
-    DL_FOREACH2(head,e,Next)
+    DL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting tail c\n");
     DL_DELETE2(head,&els[2],Prev,Next);
-    DL_FOREACH2(head,e,Next)
+    DL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head a\n");
     DL_DELETE2(head,&els[0],Prev,Next);
-    DL_FOREACH2(head,e,Next)
+    DL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head b\n");
     DL_DELETE2(head,&els[1],Prev,Next);
-    DL_FOREACH2(head,e,Next)
+    DL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     /* test LL macros */
@@ -85,26 +100,30 @@ int main(int argc, char *argv[]) {
     LL_APPEND2(head,&els[0],Next);
     LL_APPEND2(head,&els[1],Next);
     LL_APPEND2(head,&els[2],Next);
-    LL_FOREACH2(head,e,Next)
+    LL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting tail c\n");
     LL_DELETE2(head,&els[2],Next);
-    LL_FOREACH2(head,e,Next)
+    LL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head a\n");
     LL_DELETE2(head,&els[0],Next);
-    LL_FOREACH2(head,e,Next)
+    LL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     printf("deleting head b\n");
     LL_DELETE2(head,&els[1],Next);
-    LL_FOREACH2(head,e,Next)
+    LL_FOREACH2(head,e,Next) {
         printf("%c ", e->id);
+    }
     printf("\n");
 
     return 0;

+ 57 - 46
tests/test79.c

@@ -9,52 +9,63 @@ typedef struct hs_t {
 } hs_t;
 
 
-static void pr(hs_t **hdpp){
-  hs_t *el, *tmp, *hdp = *hdpp;
-  HASH_ITER(hh, hdp, el, tmp){
-    printf("id %d, tag %d\n",el->id,el->tag);
-  }
+static void pr(hs_t **hdpp)
+{
+    hs_t *el, *tmp, *hdp = *hdpp;
+    HASH_ITER(hh, hdp, el, tmp) {
+        printf("id %d, tag %d\n",el->id,el->tag);
+    }
 }
 
-int main(int argc, char *argv[]) {
-
-  hs_t *hs_head=NULL, *tmp, *replaced=NULL;
-
-  tmp = (hs_t*)malloc(sizeof(hs_t));
-  if (tmp == NULL) exit(-1);
-  tmp->id = 10;
-  tmp->tag = 100;
-  HASH_REPLACE_INT(hs_head,id,tmp,replaced);
-  if(replaced == NULL)
-    printf("added %d %d\n",tmp->id,tmp->tag);
-  else
-    printf("ERROR, ended up replacing a value, replaced: %p\n",replaced);
-
-  pr(&hs_head);
-
-  tmp = (hs_t*)malloc(sizeof(hs_t));
-  if (tmp == NULL) exit(-1);
-  tmp->id=11;
-  tmp->tag = 101;
-  HASH_REPLACE_INT(hs_head,id,tmp,replaced);
-  if(replaced == NULL)
-    printf("added %d %d\n",tmp->id,tmp->tag);
-  else
-    printf("ERROR, ended up replacing a value, replaced: %p\n",replaced);
-
-  pr(&hs_head);
-
-  tmp = (hs_t*)malloc(sizeof(hs_t));
-  if (tmp == NULL) exit(-1);
-  tmp->id=11;
-  tmp->tag = 102;
-  HASH_REPLACE_INT(hs_head,id,tmp,replaced);
-  if(replaced == NULL)
-    printf("ERROR, exected to replace a value with key: %d\n",tmp->id);
-  else
-    printf("replaced %d that had tag %d with tag %d\n",tmp->id,replaced->tag,tmp->tag);
-
-  pr(&hs_head);
-
-  return 0;
+int main(int argc, char *argv[])
+{
+
+    hs_t *hs_head=NULL, *tmp, *replaced=NULL;
+
+    tmp = (hs_t*)malloc(sizeof(hs_t));
+    if (tmp == NULL) {
+        exit(-1);
+    }
+    tmp->id = 10;
+    tmp->tag = 100;
+    HASH_REPLACE_INT(hs_head,id,tmp,replaced);
+    if(replaced == NULL) {
+        printf("added %d %d\n",tmp->id,tmp->tag);
+    } else {
+        printf("ERROR, ended up replacing a value, replaced: %p\n",replaced);
+    }
+
+    pr(&hs_head);
+
+    tmp = (hs_t*)malloc(sizeof(hs_t));
+    if (tmp == NULL) {
+        exit(-1);
+    }
+    tmp->id=11;
+    tmp->tag = 101;
+    HASH_REPLACE_INT(hs_head,id,tmp,replaced);
+    if(replaced == NULL) {
+        printf("added %d %d\n",tmp->id,tmp->tag);
+    } else {
+        printf("ERROR, ended up replacing a value, replaced: %p\n",replaced);
+    }
+
+    pr(&hs_head);
+
+    tmp = (hs_t*)malloc(sizeof(hs_t));
+    if (tmp == NULL) {
+        exit(-1);
+    }
+    tmp->id=11;
+    tmp->tag = 102;
+    HASH_REPLACE_INT(hs_head,id,tmp,replaced);
+    if(replaced == NULL) {
+        printf("ERROR, exected to replace a value with key: %d\n",tmp->id);
+    } else {
+        printf("replaced %d that had tag %d with tag %d\n",tmp->id,replaced->tag,tmp->tag);
+    }
+
+    pr(&hs_head);
+
+    return 0;
 }

+ 11 - 6
tests/test8.c

@@ -8,14 +8,17 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
@@ -23,13 +26,15 @@ int main(int argc,char *argv[]) {
     }
 
     /* delete each even ID */
-    for(i=0;i<10;i+=2) {
+    for(i=0; i<10; i+=2) {
         HASH_FIND_INT(users,&i,tmp);
         if (tmp != NULL) {
             HASH_DEL(users,tmp);
             free(tmp);
             printf("deleted; num_items in hash: %u\n", user->hh.tbl->num_items);
-        } else printf("user id %d not found\n", i);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
-   return 0;
+    return 0;
 }

+ 22 - 13
tests/test80.c

@@ -1,20 +1,29 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *a;
-  int i, *p;
-  utarray_new(a, &ut_int_icd);
-  for(i=0;i<10;i++) utarray_push_back(a,&i);
-  for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) printf("%d ",*p);
-  printf("\n");
-  printf("len: %u\n\n", utarray_len(a));
+int main()
+{
+    UT_array *a;
+    int i, *p;
+    utarray_new(a, &ut_int_icd);
+    for(i=0; i<10; i++) {
+        utarray_push_back(a,&i);
+    }
+    for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    printf("len: %u\n\n", utarray_len(a));
 
-  i=11; utarray_insert(a, &i, 11);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p); printf("\n");
-  printf("len: %u\n\n", utarray_len(a));
+    i=11;
+    utarray_insert(a, &i, 11);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    printf("len: %u\n\n", utarray_len(a));
 
-  utarray_free(a);
-  return 0;
+    utarray_free(a);
+    return 0;
 }
 

+ 22 - 13
tests/test81.c

@@ -1,20 +1,29 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *a;
-  int i, *p;
-  utarray_new(a, &ut_int_icd);
-  for(i=0;i<10;i++) utarray_push_back(a,&i);
-  for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) printf("%d ",*p);
-  printf("\n");
-  printf("len: %u\n\n", utarray_len(a));
+int main()
+{
+    UT_array *a;
+    int i, *p;
+    utarray_new(a, &ut_int_icd);
+    for(i=0; i<10; i++) {
+        utarray_push_back(a,&i);
+    }
+    for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    printf("len: %u\n\n", utarray_len(a));
 
-  i=10; utarray_insert(a, &i, 10);
-  while ( (p=(int*)utarray_next(a,p)) != NULL ) printf("%d ", *p); printf("\n");
-  printf("len: %u\n\n", utarray_len(a));
+    i=10;
+    utarray_insert(a, &i, 10);
+    while ( (p=(int*)utarray_next(a,p)) != NULL ) {
+        printf("%d ", *p);
+    }
+    printf("\n");
+    printf("len: %u\n\n", utarray_len(a));
 
-  utarray_free(a);
-  return 0;
+    utarray_free(a);
+    return 0;
 }
 

+ 32 - 21
tests/test82.c

@@ -1,31 +1,42 @@
 #include <stdio.h>
 #include "utarray.h"
 
-int main() {
-  UT_array *a,*b;
-  int i, *p;
-  utarray_new(a, &ut_int_icd);
-  utarray_new(b, &ut_int_icd);
+int main()
+{
+    UT_array *a,*b;
+    int i, *p;
+    utarray_new(a, &ut_int_icd);
+    utarray_new(b, &ut_int_icd);
 
-  for(i=0;i<10;i++) utarray_push_back(a,&i);
-  for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) printf("%d ",*p);
-  printf("\n");
-  printf("len: %u\n\n", utarray_len(a));
+    for(i=0; i<10; i++) {
+        utarray_push_back(a,&i);
+    }
+    for(p=(int*)utarray_front(a); p!=NULL; p=(int*)utarray_next(a,p)) {
+        printf("%d ",*p);
+    }
+    printf("\n");
+    printf("len: %u\n\n", utarray_len(a));
 
-  utarray_inserta(b,a,10);
-  for(p=(int*)utarray_front(b); p!=NULL; p=(int*)utarray_next(b,p)) printf("%d ",*p);
-  printf("len: %u\n\n", utarray_len(b));
+    utarray_inserta(b,a,10);
+    for(p=(int*)utarray_front(b); p!=NULL; p=(int*)utarray_next(b,p)) {
+        printf("%d ",*p);
+    }
+    printf("len: %u\n\n", utarray_len(b));
 
-  utarray_inserta(b,a,0);
-  for(p=(int*)utarray_front(b); p!=NULL; p=(int*)utarray_next(b,p)) printf("%d ",*p);
-  printf("len: %u\n\n", utarray_len(b));
+    utarray_inserta(b,a,0);
+    for(p=(int*)utarray_front(b); p!=NULL; p=(int*)utarray_next(b,p)) {
+        printf("%d ",*p);
+    }
+    printf("len: %u\n\n", utarray_len(b));
 
-  utarray_inserta(b,a,25);
-  for(p=(int*)utarray_front(b); p!=NULL; p=(int*)utarray_next(b,p)) printf("%d ",*p);
-  printf("len: %u\n\n", utarray_len(b));
+    utarray_inserta(b,a,25);
+    for(p=(int*)utarray_front(b); p!=NULL; p=(int*)utarray_next(b,p)) {
+        printf("%d ",*p);
+    }
+    printf("len: %u\n\n", utarray_len(b));
 
-  utarray_free(a);
-  utarray_free(b);
-  return 0;
+    utarray_free(a);
+    utarray_free(b);
+    return 0;
 }
 

+ 14 - 6
tests/test83.c

@@ -8,16 +8,20 @@ typedef struct person_t {
     UT_hash_handle hh;
 } person_t;
 
-int main(int argc, char*argv[]) {
+int main(int argc, char*argv[])
+{
     person_t *people=NULL, *person, *new_person, *tmp;
     const char **name;
     const char * names[] = { "bob", "jack", "gary", "ty", "bo", "phil", "art",
-                      "gil", "buck", "ted", NULL };
+                             "gil", "buck", "ted", NULL
+                           };
     int id=0;
 
     for(name=names; *name!=NULL; name++) {
         person = (person_t*)malloc(sizeof(person_t));
-        if (person == NULL) exit(-1);
+        if (person == NULL) {
+            exit(-1);
+        }
         strncpy(person->first_name, *name,sizeof(person->first_name));
         person->id = id++;
         HASH_ADD_STR(people,first_name,person);
@@ -32,12 +36,16 @@ int main(int argc, char*argv[]) {
         if (person != NULL) {
             printf("found %s (id %d)\n", person->first_name, person->id);
             new_person  = malloc(sizeof(person_t));
-            if (new_person == NULL) exit(-1);
+            if (new_person == NULL) {
+                exit(-1);
+            }
             memcpy(new_person, person, sizeof(person_t));
             new_person->id = person->id*10;
             HASH_REPLACE_STR(people,first_name,new_person,tmp);
             printf("replaced (%c) with %s (id %d)\n", (tmp!=NULL)?'y':'n', new_person->first_name, new_person->id);
-            if (tmp != NULL) free(tmp);
+            if (tmp != NULL) {
+                free(tmp);
+            }
         } else {
             printf("failed to find %s\n", *name);
         }
@@ -49,5 +57,5 @@ int main(int argc, char*argv[]) {
         HASH_DEL(people,person);
         free(person);
     }
-   return 0;
+    return 0;
 }

+ 21 - 8
tests/test84.c

@@ -8,18 +8,24 @@ typedef struct person_t {
     UT_hash_handle hh;
 } person_t;
 
-int main(int argc, char*argv[]) {
+int main(int argc, char*argv[])
+{
     person_t *people=NULL, *person, *new_person, *tmp;
     const char **name;
     const char * names[] = { "bob", "jack", "gary", "ty", "bo", "phil", "art",
-                      "gil", "buck", "ted", NULL };
+                             "gil", "buck", "ted", NULL
+                           };
     int id=0;
 
     for(name=names; *name!=NULL; name++) {
         person = (person_t*)malloc(sizeof(person_t));
-        if (person == NULL) exit(-1);
+        if (person == NULL) {
+            exit(-1);
+        }
         person->first_name = malloc(10UL);
-        if (person->first_name == NULL) exit(-1);
+        if (person->first_name == NULL) {
+            exit(-1);
+        }
         strncpy(person->first_name, *name,10UL);
         person->id = id++;
         HASH_ADD_STR(people,first_name,person);
@@ -34,14 +40,21 @@ int main(int argc, char*argv[]) {
         if (person != NULL) {
             printf("found %s (id %d)\n", person->first_name, person->id);
             new_person  = malloc(sizeof(person_t));
-            if (new_person == NULL) exit(-1);
+            if (new_person == NULL) {
+                exit(-1);
+            }
             new_person->first_name = malloc(10UL);
-            if (new_person->first_name == NULL) exit(-1);
+            if (new_person->first_name == NULL) {
+                exit(-1);
+            }
             strncpy(new_person->first_name, person->first_name,10UL);
             new_person->id = person->id*10;
             HASH_REPLACE_STR(people,first_name,new_person,tmp);
             printf("replaced (%c) with %s (id %d)\n", (tmp!=NULL)?'y':'n', new_person->first_name, new_person->id);
-            if (tmp != NULL) {free(tmp->first_name); free(tmp);}
+            if (tmp != NULL) {
+                free(tmp->first_name);
+                free(tmp);
+            }
         } else {
             printf("failed to find %s\n", *name);
         }
@@ -54,5 +67,5 @@ int main(int argc, char*argv[]) {
         free(person->first_name);
         free(person);
     }
-   return 0;
+    return 0;
 }

+ 14 - 11
tests/test85.c

@@ -8,25 +8,28 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *users=NULL;
 
     /* create elements */
-    for(i=0;i<10;i++) {
+    for(i=0; i<10; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
-   size_t s = HASH_OVERHEAD(hh,users);
-   printf("overhead %s\n", (s==0U)?"zero":"non-zero");
-   HASH_CLEAR(hh,users);  
-   // should free those elements 
-   // but this test is not concerned with that
-   s = HASH_OVERHEAD(hh,users);
-   printf("overhead %s\n", (s==0U)?"zero":"non-zero");
-   return 0;
+    size_t s = HASH_OVERHEAD(hh,users);
+    printf("overhead %s\n", (s==0U)?"zero":"non-zero");
+    HASH_CLEAR(hh,users);
+    // should free those elements
+    // but this test is not concerned with that
+    s = HASH_OVERHEAD(hh,users);
+    printf("overhead %s\n", (s==0U)?"zero":"non-zero");
+    return 0;
 }

+ 11 - 6
tests/test9.c

@@ -8,25 +8,30 @@ typedef struct example_user_t {
     UT_hash_handle hh;
 } example_user_t;
 
-int main(int argc,char *argv[]) {
+int main(int argc,char *argv[])
+{
     int i;
     example_user_t *user, *tmp, *users=NULL;
 
     /* create elements */
-    for(i=0;i<1000;i++) {
+    for(i=0; i<1000; i++) {
         user = (example_user_t*)malloc(sizeof(example_user_t));
-        if (user == NULL) exit(-1);
+        if (user == NULL) {
+            exit(-1);
+        }
         user->id = i;
         user->cookie = i*i;
         HASH_ADD_INT(users,id,user);
     }
 
     /* delete each ID */
-    for(i=0;i<1000;i+=2) {
+    for(i=0; i<1000; i+=2) {
         HASH_FIND_INT(users,&i,tmp);
         if (tmp != NULL) {
             printf("user %d, cookie %d\n", tmp->id, tmp->cookie);
-        } else printf("user id %d not found\n", i);
+        } else {
+            printf("user id %d not found\n", i);
+        }
     }
-   return 0;
+    return 0;
 }