From c5ac8e8d8e4b38d0beddbcd19c2dc791c76bf776 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Sat, 30 Dec 2017 17:38:07 +0800 Subject: [PATCH] Optimize code Signed-off-by: Jianhui Zhao --- src/action.c | 2 +- src/action.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/action.c b/src/action.c index d338237..d25a102 100755 --- a/src/action.c +++ b/src/action.c @@ -29,7 +29,7 @@ int uh_add_action(struct uh_server *srv, const char *path, action_cb_t cb) { struct uh_action *a; - a = calloc(1, sizeof(struct uh_action)); + a = calloc(1, sizeof(struct uh_action) + strlen(path) + 1); if (!a) { uh_log_err("calloc"); return -1; diff --git a/src/action.h b/src/action.h index 9a368ea..2eb4e9f 100755 --- a/src/action.h +++ b/src/action.h @@ -28,8 +28,8 @@ typedef void (*action_cb_t)(struct uh_client *cl); struct uh_action { struct avl_node avl; - char path[PATH_MAX]; action_cb_t cb; + char path[0]; }; int uh_add_action(struct uh_server *srv, const char *path, action_cb_t cb);