diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-11-25 14:51:10 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-11-25 14:51:10 -0600 |
commit | b845f19a3bb200e49a7a314787b3290e3155ce01 (patch) | |
tree | 51d3d2e4887b9a950b1e7d85c61359544c7f547c /apps/examples/wgetjson | |
parent | f7de6bbcbae818aff936bd71ee5268946ea9ad30 (diff) | |
download | px4-nuttx-b845f19a3bb200e49a7a314787b3290e3155ce01.tar.gz px4-nuttx-b845f19a3bb200e49a7a314787b3290e3155ce01.tar.bz2 px4-nuttx-b845f19a3bb200e49a7a314787b3290e3155ce01.zip |
Fixes for more cppcheck complaints. Mostly cosmetic
Diffstat (limited to 'apps/examples/wgetjson')
-rw-r--r-- | apps/examples/wgetjson/wgetjson_main.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/examples/wgetjson/wgetjson_main.c b/apps/examples/wgetjson/wgetjson_main.c index 724b3b5b1..7dafbcb44 100644 --- a/apps/examples/wgetjson/wgetjson_main.c +++ b/apps/examples/wgetjson/wgetjson_main.c @@ -83,9 +83,9 @@ * Private Data ****************************************************************************/ -static char *g_json_buff = NULL; -static int g_json_bufflen = 0; -static bool g_has_json = false; +static FAR char *g_json_buff = NULL; +static int g_json_bufflen = 0; +static bool g_has_json = false; /**************************************************************************** * Private Functions @@ -113,7 +113,9 @@ static void wgetjson_postdebug_callback(FAR char **buffer, int offset, static void wgetjson_callback(FAR char **buffer, int offset, int datend, FAR int *buflen, FAR void *arg) { - int len = datend - offset,org=len; + FAR char *new_json_buff; + int len = datend - offset; + int org = len; if (len <= 0) { @@ -140,10 +142,14 @@ static void wgetjson_callback(FAR char **buffer, int offset, int datend, len = CONFIG_EXAMPLES_WGETJSON_MAXSIZE - g_json_bufflen; } - g_json_buff = realloc(g_json_buff, g_json_bufflen + len + 1); - memcpy(&g_json_buff[g_json_bufflen-1], &((*buffer)[offset]), len); - g_json_buff[g_json_bufflen + len] = 0; - g_json_bufflen += org; + new_json_buff = (FAR char *)realloc(g_json_buff, g_json_bufflen + len + 1); + if (new_json_buff) + { + g_json_buff = new_json_buff; + memcpy(&g_json_buff[g_json_bufflen-1], &((*buffer)[offset]), len); + g_json_buff[g_json_bufflen + len] = 0; + g_json_bufflen += org; + } } } |