diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-12-15 09:12:43 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-12-15 09:12:43 +0100 |
commit | cce716909e5236f1aa2971a4db45a007c7efe416 (patch) | |
tree | fe8e79c192427befd5760a2aa6b444931bf23362 /src/st.c | |
parent | 81f65b49e828952d496c80a991397fdac96feea9 (diff) |
New upstream version 6.1.3upstream/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]; |