#include "ptable.h"
#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))
#define ptable_free(T) ptable_free(aTHX_ (T))
return INT2PTR(const char *, SvUVX(val));
}
+STATIC void indirect_map_delete(pTHX_ const OP *o) {
+#define indirect_map_delete(O) indirect_map_delete(aTHX_ (O))
+ dMY_CXT;
+
+ ptable_delete(MY_CXT.map, o);
+}
+
/* --- Check functions ----------------------------------------------------- */
STATIC const char *indirect_find(pTHX_ SV *sv, const char *s) {
if (indirect_hint()) {
SV *sv = cSVOPo_sv;
- if (SvPOK(sv) && (SvTYPE(sv) >= SVt_PV))
+ if (SvPOK(sv) && (SvTYPE(sv) >= SVt_PV)) {
indirect_map_store(o, indirect_find(sv, PL_oldbufptr), sv);
+ return o;
+ }
}
+ indirect_map_delete(o);
return o;
}
}
done:
- return CALL_FPTR(indirect_old_ck_rv2sv)(aTHX_ o);
+ o = CALL_FPTR(indirect_old_ck_rv2sv)(aTHX_ o);
+
+ indirect_map_delete(o);
+ return o;
}
/* ... ck_padany ........................................................... */
sv = sv_2mortal(newSVpvn("$", 1));
sv_catpvn_nomg(sv, s, t - s + 1);
indirect_map_store(o, s, sv);
+ return o;
}
}
+ indirect_map_delete(o);
return o;
}
}
done:
- return CALL_FPTR(indirect_old_ck_method)(aTHX_ o);
+ o = CALL_FPTR(indirect_old_ck_method)(aTHX_ o);
+
+ indirect_map_delete(o);
+ return o;
}
/* ... ck_entersub ......................................................... */
oop = oop->op_sibling;
mop = lop->op_last;
+ if (!oop)
+ goto done;
+
+ switch (oop->op_type) {
+ case OP_CONST:
+ case OP_RV2SV:
+ case OP_PADSV:
+ break;
+ default:
+ goto done;
+ }
+
if (mop->op_type == OP_METHOD)
mop = cUNOPx(mop)->op_first;
else if (mop->op_type != OP_METHOD_NAMED)
}
#endif /* !ptable_fetch */
+STATIC void PTABLE_PREFIX(_delete)(pPTBL_ const ptable * const t, const void * const key) {
+ ptable_ent *const ent = ptable_find(t, key);
+
+ if (ent) {
+ void *val = ent->val;
+ PTABLE_VAL_FREE(val);
+ ent->val = NULL;
+ }
+}
+
#ifndef ptable_split
STATIC void ptable_split(pPTBLMS_ ptable * const t) {
#define ptable_split(T) ptable_split(aPTBLMS_ (T))