Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
errno isn't used so remove include of errno.h.
initialize json to NULL to avoid realloc crash.
use memset instead of obsolete bzero.
  • Loading branch information
Bruce Cran committed Jan 19, 2011
1 parent 163971a commit c3eade0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions js0n_test.c
@@ -1,12 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "js0n.h"

int main(int argc, char **argv)
{
unsigned char buff[1024], *json;
unsigned char buff[1024], *json = NULL;
int len, lastlen=0, ret, i;
unsigned short *res;
FILE *f;
Expand All @@ -25,7 +24,7 @@ int main(int argc, char **argv)
fclose(f);
printf("got[%.*s]\n",lastlen,json);
res = malloc(lastlen); // way more than enough
bzero(res,lastlen);
memset(res,0,lastlen);
ret = js0n(json,lastlen,res);
printf("returned %d\n",ret);
for(i=0;res[i];i+=2)
Expand Down

0 comments on commit c3eade0

Please sign in to comment.