Don't like ads? PRO users don't see any ads ;-)
Guest

Freeing heap problem with jansson using C

By: a guest on Jul 6th, 2012  |  syntax: C  |  size: 0.28 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<stdio.h>
  2.  
  3. #include<malloc.h>
  4.  
  5. #include<jansson.h>
  6.  
  7. int main()
  8. {
  9.         json_t * tuple;
  10.         char * test = (char *)malloc(200);
  11.        
  12.         tuple= json_pack("{s:s}" , "key" , "121564456465");
  13.         test = json_dumps(tuple,0);
  14.        
  15.         puts(test);
  16.         free(test);
  17.         json_decref(tuple);
  18.         return 0 ;
  19. }