moonbridge

diff moonbridge.c @ 211:a3d569d3e85d

Avoid use of asprintf function
author jbe
date Mon Jun 22 21:26:33 2015 +0200 (2015-06-22)
parents 05fd82e3cfb7
children 453b7d1a7944
line diff
     1.1 --- a/moonbridge.c	Mon Jun 22 21:17:17 2015 +0200
     1.2 +++ b/moonbridge.c	Mon Jun 22 21:26:33 2015 +0200
     1.3 @@ -42,9 +42,6 @@
     1.4  #if defined(__FreeBSD__) || __has_include(<libutil.h>)
     1.5  #include <libutil.h>
     1.6  #endif
     1.7 -#if defined(__linux__) || __has_include(<bsd/stdio.h>)
     1.8 -#include <bsd/stdio.h>
     1.9 -#endif
    1.10  #if defined(__linux__) || __has_include(<bsd/libutil.h>)
    1.11  #include <bsd/libutil.h>
    1.12  #endif
    1.13 @@ -1911,10 +1908,12 @@
    1.14        {
    1.15          const char *name = lua_tostring(L, -1);
    1.16          if (name) {
    1.17 -          if (asprintf(&listener->type_specific.interval.name, "%s", name) < 0) {
    1.18 +          char *name_dup = strdup(name);
    1.19 +          if (!name_dup) {
    1.20              moonbr_log(LOG_CRIT, "Memory allocation_error");
    1.21              moonbr_terminate_error();
    1.22            }
    1.23 +          listener->type_specific.interval.name = name_dup;
    1.24          }
    1.25        }
    1.26        lua_getfield(L, 3, "delay");

Impressum / About Us