diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 12:29:22 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 12:29:22 +0100 |
commit | ba53137f1b687b1c9cbd66fbe306ed1bf6d0cccb (patch) | |
tree | 55cebfa7f54b14601eccbd1bf1f50e33ceee5d76 /src/kernel | |
parent | 630c28c3fd3297c7a0ea7ec7ad4417f521fdaa7f (diff) | |
download | kogata-ba53137f1b687b1c9cbd66fbe306ed1bf6d0cccb.tar.gz kogata-ba53137f1b687b1c9cbd66fbe306ed1bf6d0cccb.zip |
Change hashtbl memory freeing method
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/core/kmain.c | 8 | ||||
-rw-r--r-- | src/kernel/user/nullfs.c | 8 | ||||
-rw-r--r-- | src/kernel/user/process.c | 4 | ||||
-rw-r--r-- | src/kernel/user/vfs.c | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c index ee6d8b2..ce3f536 100644 --- a/src/kernel/core/kmain.c +++ b/src/kernel/core/kmain.c @@ -125,7 +125,7 @@ void kmalloc_test(void* kernel_data_end) { void test_hashtbl_1() { dbg_printf("(BEGIN-TEST 'test-hashtbl-1)\n"); // hashtable test - hashtbl_t *ht = create_hashtbl(str_key_eq_fun, str_hash_fun, 0, 0); + hashtbl_t *ht = create_hashtbl(str_key_eq_fun, str_hash_fun, 0); ASSERT(ht != 0); ASSERT(hashtbl_add(ht, "test1", "STRTEST1")); @@ -151,7 +151,7 @@ void test_hashtbl_1() { ASSERT(hashtbl_find(ht, "test") != 0 && strcmp(hashtbl_find(ht, "test"), "Forever alone") == 0); - delete_hashtbl(ht, 0); + delete_hashtbl(ht); dbg_printf("(TEST-OK)\n"); } @@ -159,7 +159,7 @@ void test_hashtbl_1() { void test_hashtbl_2() { dbg_printf("(BEGIN-TEST 'test-hashtbl-2)\n"); - hashtbl_t *ht = create_hashtbl(id_key_eq_fun, id_hash_fun, 0, 0); + hashtbl_t *ht = create_hashtbl(id_key_eq_fun, id_hash_fun, 0); ASSERT(ht != 0); ASSERT(hashtbl_add(ht, (void*)12, "TESTSTR12")); @@ -187,7 +187,7 @@ void test_hashtbl_2() { ASSERT(hashtbl_find(ht, (void*)777) != 0 && strcmp(hashtbl_find(ht, (void*)777), "TESTSTR777") == 0); - delete_hashtbl(ht, 0); + delete_hashtbl(ht); dbg_printf("(TEST-OK)\n"); } diff --git a/src/kernel/user/nullfs.c b/src/kernel/user/nullfs.c index 1685f4c..97f3d00 100644 --- a/src/kernel/user/nullfs.c +++ b/src/kernel/user/nullfs.c @@ -149,7 +149,7 @@ bool nullfs_fs_make(fs_handle_t *source, char* opts, fs_t *fs_s) { root->fs = fs; root->items_list = 0; root->lock = MUTEX_UNLOCKED; - root->items_idx = create_hashtbl(str_key_eq_fun, str_hash_fun, 0, 0); + root->items_idx = create_hashtbl(str_key_eq_fun, str_hash_fun, 0); if (root->items_idx == 0) { free(root); free(fs); @@ -308,7 +308,7 @@ bool nullfs_d_delete(fs_node_ptr n, const char* file) { nullfs_dir_t* sd = (nullfs_dir_t*)i->data; if (sd->items_list != 0) return false; - delete_hashtbl(sd->items_idx, 0); + delete_hashtbl(sd->items_idx); free(sd); } else if (i->ops == &nullfs_f_ops) { nullfs_file_t* f = (nullfs_file_t*)i->data; @@ -384,7 +384,7 @@ bool nullfs_d_create(fs_node_ptr n, const char* file, int type) { nullfs_dir_t *x = (nullfs_dir_t*)malloc(sizeof(nullfs_dir_t)); if (x == 0) return false; - x->items_idx = create_hashtbl(str_key_eq_fun, str_hash_fun, 0, 0); + x->items_idx = create_hashtbl(str_key_eq_fun, str_hash_fun, 0); if (x->items_idx == 0) goto d_error; x->items_list = 0; @@ -411,7 +411,7 @@ bool nullfs_d_create(fs_node_ptr n, const char* file, int type) { d_error: if (i != 0 && i->name != 0) free(i->name); if (i != 0) free(i); - if (x->items_idx != 0) delete_hashtbl(x->items_idx, 0); + if (x->items_idx != 0) delete_hashtbl(x->items_idx); free(x); return false; } else { diff --git a/src/kernel/user/process.c b/src/kernel/user/process.c index d1fdf32..2f3cac1 100644 --- a/src/kernel/user/process.c +++ b/src/kernel/user/process.c @@ -35,7 +35,7 @@ process_t *new_process(process_t *parent) { process_t *proc = (process_t*)malloc(sizeof(process_t)); if (proc == 0) return 0; - proc->filesystems = create_hashtbl(str_key_eq_fun, str_hash_fun, free, 0); + proc->filesystems = create_hashtbl(str_key_eq_fun, str_hash_fun, free_key); if (proc->filesystems == 0) { free(proc); return 0; @@ -43,7 +43,7 @@ process_t *new_process(process_t *parent) { proc->pd = create_pagedir(proc_usermem_pf, proc); if (proc->pd == 0) { - delete_hashtbl(proc->filesystems, 0); + delete_hashtbl(proc->filesystems); free(proc); return 0; } diff --git a/src/kernel/user/vfs.c b/src/kernel/user/vfs.c index 0624a38..1f7bacd 100644 --- a/src/kernel/user/vfs.c +++ b/src/kernel/user/vfs.c @@ -95,7 +95,7 @@ void unref_fs_node(fs_node_t *n) { unref_fs_node(n->parent); unref_fs(n->fs); - if (n->children != 0) delete_hashtbl(n->children, 0); + if (n->children != 0) delete_hashtbl(n->children); free(n->name); free(n); } @@ -126,7 +126,7 @@ fs_node_t* fs_walk_one(fs_node_t* from, const char* file) { if (!walk_ok) goto error; if (from->children == 0) { - from->children = create_hashtbl(str_key_eq_fun, str_hash_fun, 0, 0); + from->children = create_hashtbl(str_key_eq_fun, str_hash_fun, 0); if (from->children == 0) goto error; } |