diff options
author | Jakub Grajciar <jgrajcia@cisco.com> | 2018-03-13 13:57:50 +0100 |
---|---|---|
committer | Jakub Grajciar <jgrajcia@cisco.com> | 2018-03-13 16:13:46 +0100 |
commit | 1941871e2622a17e84062c69c234414c4dc2bf4a (patch) | |
tree | 1743dcdc712f471839b096bf519173c55fb0a34d /extras/libmemif/src/main.c | |
parent | 3464c860650c5d8cc8abf11c7d2faa074105b8d6 (diff) |
libmemif: ubuntu 18.04 build fix
Change-Id: I6624cacd625eea6a9b8214f67d14ec162e2c0195
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras/libmemif/src/main.c')
-rw-r--r-- | extras/libmemif/src/main.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/extras/libmemif/src/main.c b/extras/libmemif/src/main.c index 372bf756a02..cb24083c8e3 100644 --- a/extras/libmemif/src/main.c +++ b/extras/libmemif/src/main.c @@ -406,17 +406,16 @@ memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name) { int err = MEMIF_ERR_SUCCESS; /* 0 */ libmemif_main_t *lm = &libmemif_main; + memset (lm, 0, sizeof (libmemif_main_t)); if (app_name) { - lm->app_name = malloc (strlen (app_name) + sizeof (char)); - memset (lm->app_name, 0, strlen (app_name) + sizeof (char)); + uint8_t len = (strlen (app_name) < MEMIF_NAME_LEN) + ? MEMIF_NAME_LEN : strlen (app_name); strncpy ((char *) lm->app_name, app_name, strlen (app_name)); } else { - lm->app_name = malloc (strlen (MEMIF_DEFAULT_APP_NAME) + sizeof (char)); - memset (lm->app_name, 0, strlen (app_name) + sizeof (char)); strncpy ((char *) lm->app_name, MEMIF_DEFAULT_APP_NAME, strlen (MEMIF_DEFAULT_APP_NAME)); } @@ -438,8 +437,6 @@ memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name) DBG ("libmemif event polling initialized"); } - memset (&lm->ms, 0, sizeof (memif_socket_t)); - lm->control_list_len = 2; lm->interrupt_list_len = 2; lm->listener_list_len = 1; @@ -490,7 +487,6 @@ memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name) lm->arm.it_value.tv_nsec = 0; lm->arm.it_interval.tv_sec = 2; lm->arm.it_interval.tv_nsec = 0; - memset (&lm->disarm, 0, sizeof (lm->disarm)); if (lm->control_fd_update (lm->timerfd, MEMIF_FD_EVENT_READ) < 0) { @@ -2096,9 +2092,6 @@ int memif_cleanup () { libmemif_main_t *lm = &libmemif_main; - if (lm->app_name) - free (lm->app_name); - lm->app_name = NULL; if (lm->control_list) free (lm->control_list); lm->control_list = NULL; |