]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - indirect.xs
Update XS helpers to 18554226
[perl/modules/indirect.git] / indirect.xs
index 0545e0149a56a33fa28e35cdfc382a3a1a1283f4..9e8dc99bdb995fd2979471cf13dadbb945cb04ab 100644 (file)
@@ -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);