#include "sub_op.h"
-void sub_op_register(pTHX_ const sub_op_config_t *c) {
+void sub_op_init(sub_op_config_t *c) {
+ c->name = NULL;
+ c->namelen = 0;
+ c->pp = 0;
+ c->check = 0;
+ c->ud = NULL;
+
+ return;
+}
+
+void sub_op_register(pTHX_ const sub_op_config_t *c, U32 flags) {
SV *key = newSViv(PTR2IV(c->pp));
if (!PL_custom_op_names)
PL_custom_op_names = newHV();
- (void) hv_store_ent(PL_custom_op_names, key, newSVpv(c->name, c->len), 0);
+ (void) hv_store_ent(PL_custom_op_names, key, newSVpv(c->name, c->namelen), 0);
if (!PL_custom_op_descs)
PL_custom_op_descs = newHV();
- (void) hv_store_ent(PL_custom_op_descs, key, newSVpv(c->name, c->len), 0);
+ (void) hv_store_ent(PL_custom_op_descs, key, newSVpv(c->name, c->namelen), 0);
if (c->check) {
SV *check = newSViv(PTR2IV(c->check));
{
dMY_CXT;
- (void) hv_store(MY_CXT.map, c->name, c->len, key, 0);
+ (void) hv_store(MY_CXT.map, c->name, c->namelen, key, 0);
}
}
+sub_op_config_t *sub_op_dup(pTHX_ const sub_op_config_t *orig) {
+ sub_op_config_t *dupe = PerlMemShared_malloc(sizeof *dupe);
+
+ dupe->namelen = orig->namelen;
+ dupe->name = PerlMemShared_malloc(dupe->namelen);
+ Copy(orig->name, dupe->name, dupe->namelen, char);
+
+ dupe->pp = orig->pp;
+ dupe->check = orig->check;
+ dupe->ud = orig->ud;
+
+ return dupe;
+}
+
+void sub_op_free(pTHX_ sub_op_config_t *c) {
+ PerlMemShared_free((char *) c->name);
+ PerlMemShared_free(c);
+
+ return;
+}
+
/* --- Private helpers ----------------------------------------------------- */
STATIC IV so_hint(pTHX) {