#include "xsh/caps.h"
#include "xsh/util.h"
+#include "xsh/mem.h"
#include "xsh/ops.h"
/* ... op => source position map ........................................... */
} 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))
/* --- Compatibility wrappers ---------------------------------------------- */
-#ifndef Newx
-# define Newx(v, n, c) New(0, v, n, c)
-#endif
-
#ifndef SvPV_const
# define SvPV_const SvPV
#endif
* 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;
}
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);