Skip to content

Commit

Permalink
does not use the GC memory in json
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Mar 3, 2012
1 parent 7e149f1 commit 64b2cf6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ext/json/fbuffer/fbuffer.h
Expand Up @@ -5,6 +5,20 @@
#include <assert.h>
#include "ruby.h"

#ifdef __MACRUBY__
/* We cannot use the GC memory functions here
* function will call free() on the memory, resulting in a leak.
*/
# undef ALLOC
# define ALLOC(type) (type*)malloc(sizeof(type))
# undef ALLOC_N
# define ALLOC_N(type,n) ((type *)malloc(sizeof(type) * (n)))
# undef REALLOC_N
# define REALLOC_N(var,type,n) \
(var)=(type*)realloc((char*)(var),(n) * sizeof(type))
# define ruby_xfree(x) free(x)
#endif

#ifdef HAVE_RUBY_ENCODING_H
#include "ruby/encoding.h"
#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
Expand Down

0 comments on commit 64b2cf6

Please sign in to comment.