moonbridge
changeset 211:a3d569d3e85d
Avoid use of asprintf function
author | jbe |
---|---|
date | Mon Jun 22 21:26:33 2015 +0200 (2015-06-22) |
parents | 7967c1e4f6d1 |
children | 453b7d1a7944 |
files | moonbridge.c moonbridge_io.c |
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");
2.1 --- a/moonbridge_io.c Mon Jun 22 21:17:17 2015 +0200 2.2 +++ b/moonbridge_io.c Mon Jun 22 21:26:33 2015 +0200 2.3 @@ -27,7 +27,7 @@ 2.4 #if defined(__linux__) || __has_include(<bsd/unistd.h>) 2.5 #include <bsd/unistd.h> 2.6 #endif 2.7 - 2.8 + 2.9 #include <lua.h> 2.10 #include <lauxlib.h> 2.11 #include <lualib.h>