diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-09-02 14:23:09 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-09-02 14:23:09 -0700 |
commit | b758b29f5842d60933d98c1c292f00f73fedf24b (patch) | |
tree | 6ecc1de7e6a947b907fa20f9c4931a7c0954d384 /ext/rpatricia/patricia.c | |
parent | 03daddf53a88bf1a3b7890d02577dd8921d70b76 (diff) | |
download | rpatricia-b758b29f5842d60933d98c1c292f00f73fedf24b.tar.gz |
make allocations go through xcalloc in Ruby
Ruby's xcalloc() has built-in failure handling and will force GC to run if memory is needed. Patricia.new will no longer fail with anything other than NoMemoryError, which rare.
Diffstat (limited to 'ext/rpatricia/patricia.c')
-rw-r--r-- | ext/rpatricia/patricia.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/rpatricia/patricia.c b/ext/rpatricia/patricia.c index d211a34..7fc3d27 100644 --- a/ext/rpatricia/patricia.c +++ b/ext/rpatricia/patricia.c @@ -31,7 +31,13 @@ static char copyright[] = #include "patricia.h" -#define Delete free +#if defined(HAVE_RUBY_XCALLOC) +# include <ruby.h> +# define calloc xcalloc +# define Delete xfree +#else +# define Delete free +#endif /* { from prefix.c */ |