X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=indirect.xs;fp=indirect.xs;h=9e8dc99bdb995fd2979471cf13dadbb945cb04ab;hp=0545e0149a56a33fa28e35cdfc382a3a1a1283f4;hb=b2f0fe94a79e6c4426f2b566bd06e5acf9f42c02;hpb=7b9a8ae944bb32360e3a8807ec6cb05376fd4183 diff --git a/indirect.xs b/indirect.xs index 0545e01..9e8dc99 100644 --- a/indirect.xs +++ b/indirect.xs @@ -12,6 +12,7 @@ #include "xsh/caps.h" #include "xsh/util.h" +#include "xsh/mem.h" #include "xsh/ops.h" /* ... op => source position map ........................................... */ @@ -25,13 +26,13 @@ typedef struct { } indirect_op_info_t; #define PTABLE_NAME ptable -#define PTABLE_VAL_FREE(V) if (V) { Safefree(((indirect_op_info_t *) (V))->buf); Safefree(V); } +#define PTABLE_VAL_FREE(V) if (V) { indirect_op_info_t *oi = (V); XSH_LOCAL_FREE(oi->buf, oi->size, char); XSH_LOCAL_FREE(oi, 1, indirect_op_info_t); } #define PTABLE_NEED_DELETE 1 #define PTABLE_NEED_WALK 0 #include "xsh/ptable.h" -/* Safefree() always need aTHX */ +/* XSH_LOCAL_FREE() always need aTHX */ #define ptable_store(T, K, V) ptable_store(aTHX_ (T), (K), (V)) #define ptable_delete(T, K) ptable_delete(aTHX_ (T), (K)) #define ptable_clear(T) ptable_clear(aTHX_ (T)) @@ -92,10 +93,6 @@ static SV *indirect_hint(pTHX) { /* --- Compatibility wrappers ---------------------------------------------- */ -#ifndef Newx -# define Newx(v, n, c) New(0, v, n, c) -#endif - #ifndef SvPV_const # define SvPV_const SvPV #endif @@ -241,7 +238,7 @@ static void indirect_map_store(pTHX_ const OP *o, STRLEN pos, SV *sv, line_t lin * guarded by indirect_hint(). */ if (!(oi = ptable_fetch(XSH_CXT.map, o))) { - Newx(oi, 1, indirect_op_info_t); + XSH_LOCAL_ALLOC(oi, 1, indirect_op_info_t); ptable_store(XSH_CXT.map, o, oi); oi->buf = NULL; oi->size = 0; @@ -255,8 +252,7 @@ static void indirect_map_store(pTHX_ const OP *o, STRLEN pos, SV *sv, line_t lin } if (len > oi->size) { - Safefree(oi->buf); - Newx(oi->buf, len, char); + XSH_LOCAL_REALLOC(oi->buf, oi->size, len, char); oi->size = len; } Copy(s, oi->buf, len, char);