diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-12-15 09:12:46 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-12-15 09:12:46 +0100 |
commit | 2183181a37a0d2748ec5249802431d7634dee3bb (patch) | |
tree | 898265b12ecb88c220745e02aa74f3f8af2a2443 /src/st.c | |
parent | f73bfdc31b21e34ba1bd6338e01be3af6c3cb89e (diff) | |
parent | cce716909e5236f1aa2971a4db45a007c7efe416 (diff) |
Merge tag 'upstream/6.1.3'
Upstream version 6.1.3
Diffstat (limited to 'src/st.c')
-rw-r--r-- | src/st.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -130,11 +130,13 @@ static int collision = 0; static int init_st = 0; static void -stat_col() +stat_col(void) { - FILE *f = fopen("/tmp/col", "w"); - fprintf(f, "collision: %d\n", collision); - fclose(f); + FILE *f = fopen("/tmp/col", "w"); + if (f == 0) return ; + + (void) fprintf(f, "collision: %d\n", collision); + (void) fclose(f); } #endif @@ -155,10 +157,16 @@ st_init_table_with_size(type, size) size = new_size(size); /* round up to prime number */ tbl = alloc(st_table); + if (tbl == 0) return 0; + tbl->type = type; tbl->num_entries = 0; tbl->num_bins = size; tbl->bins = (st_table_entry **)Calloc(size, sizeof(st_table_entry*)); + if (tbl->bins == 0) { + free(tbl); + return 0; + } return tbl; } @@ -320,6 +328,9 @@ rehash(table) new_num_bins = new_size(old_num_bins+1); new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*)); + if (new_bins == 0) { + return ; + } for(i = 0; i < old_num_bins; i++) { ptr = table->bins[i]; |