Permalink
Browse files

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...
1 parent 163971a commit c3eade0482f429256c2760cce50d7244f0c5fe2b Bruce Cran committed Jan 19, 2011
Showing with 2 additions and 3 deletions.
  1. +2 −3 js0n_test.c
View
@@ -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;
@@ -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)

0 comments on commit c3eade0

Please sign in to comment.