Optimize code

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
main
Jianhui Zhao 2017-12-30 17:38:07 +08:00
parent b5517eda7e
commit c5ac8e8d8e
2 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,7 @@ int uh_add_action(struct uh_server *srv, const char *path, action_cb_t cb)
{ {
struct uh_action *a; struct uh_action *a;
a = calloc(1, sizeof(struct uh_action)); a = calloc(1, sizeof(struct uh_action) + strlen(path) + 1);
if (!a) { if (!a) {
uh_log_err("calloc"); uh_log_err("calloc");
return -1; return -1;

View File

@ -28,8 +28,8 @@ typedef void (*action_cb_t)(struct uh_client *cl);
struct uh_action { struct uh_action {
struct avl_node avl; struct avl_node avl;
char path[PATH_MAX];
action_cb_t cb; action_cb_t cb;
char path[0];
}; };
int uh_add_action(struct uh_server *srv, const char *path, action_cb_t cb); int uh_add_action(struct uh_server *srv, const char *path, action_cb_t cb);