src/server/daemon/func.c

changeset 15
cff9c4101dd7
parent 14
b8bf95b39952
child 20
7b235fa88008
equal deleted inserted replaced
14:b8bf95b39952 15:cff9c4101dd7
28 28
29 29
30 #include <stdlib.h> 30 #include <stdlib.h>
31 31
32 #include "../public/nsapi.h" 32 #include "../public/nsapi.h"
33 #include "../util/map.h" 33
34 #include "../ucx/map.h"
35
34 #include "func.h" 36 #include "func.h"
35 37
36 hashmap_t *function_map; 38 UcxMap *function_map;
37 39
38 void func_init() { 40 void func_init() {
39 function_map = hashmap_new(128); 41 function_map = ucx_map_new(128);
40 } 42 }
41 43
42 void add_function(struct FuncStruct *func) { 44 void add_function(struct FuncStruct *func) {
43 printf("add function: %s\n", func->name); 45 printf("add function: %s\n", func->name);
44 46
45 struct FuncStruct *f = malloc(sizeof(FuncStruct)); 47 struct FuncStruct *f = malloc(sizeof(FuncStruct));
46 *f = *func; 48 *f = *func;
47 hashmap_put(function_map, sstr((char*)f->name), func); 49 ucx_map_cstr_put(function_map, (char*)f->name, func);
48 } 50 }
49 51
50 void add_functions(struct FuncStruct *funcs) { 52 void add_functions(struct FuncStruct *funcs) {
51 int i = 0; 53 int i = 0;
52 while(funcs[i].func != NULL) { 54 while(funcs[i].func != NULL) {
54 i++; 56 i++;
55 } 57 }
56 } 58 }
57 59
58 FuncStruct* get_function(char *name) { 60 FuncStruct* get_function(char *name) {
59 return hashmap_get(function_map, sstr(name)); 61 return ucx_map_cstr_get(function_map, name);
60 } 62 }

mercurial