]> git.vpit.fr Git - perl/modules/VPIT-XSHelpers.git/blobdiff - xsh/hints.h
Wrap memory-related functions into new helpers
[perl/modules/VPIT-XSHelpers.git] / xsh / hints.h
index 458b1170f06c9655bfcae6f58918ea01ea8c891a..18f674f2271414e5bf48cc27ca3f50a01ff93d4f 100644 (file)
@@ -2,6 +2,7 @@
 #define XSH_HINTS_H 1
 
 #include "caps.h" /* XSH_HAS_PERL(), XSH_THREADSAFE, tTHX */
+#include "mem.h"  /* XSH_SHARED_*() */
 
 #ifdef XSH_THREADS_H
 # error threads.h must be loaded at the very end
@@ -160,10 +161,10 @@ typedef struct {
 
 #ifdef XSH_HINTS_VAL_DEINIT
 # define XSH_HINTS_FREE(H) \
-   if (H) XSH_HINTS_VAL_DEINIT(XSH_HINTS_VAL_GET(H)); \
-   PerlMemShared_free(H)
+   if (H) XSH_HINTS_VAL_DEINIT(XSH_HINTS_VAL_GET(((xsh_hints_t *) (H)))); \
+   XSH_SHARED_FREE((H), 1, xsh_hints_t)
 #else
-# define XSH_HINTS_FREE(H) PerlMemShared_free(H)
+# define XSH_HINTS_FREE(H) XSH_SHARED_FREE((H), 1, xsh_hints_t)
 #endif
 
 #else  /*  XSH_HINTS_NEED_STRUCT */
@@ -183,7 +184,7 @@ typedef XSH_HINTS_TYPE_COMPACT xsh_hints_t;
 
 #ifdef XSH_HINTS_FREE
 # define PTABLE_NAME        ptable_hints
-# define PTABLE_VAL_FREE(V) XSH_HINTS_FREE((xsh_hints_t *) (V))
+# define PTABLE_VAL_FREE(V) XSH_HINTS_FREE(V)
 #else
 # define PTABLE_USE_DEFAULT 1
 #endif
@@ -231,7 +232,7 @@ static void xsh_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) {
  xsh_hints_t         *h2;
 
 #if XSH_HINTS_NEED_STRUCT
h2              = PerlMemShared_malloc(sizeof *h2);
XSH_SHARED_ALLOC(h2, 1, xsh_hints_t);
 # if XSH_WORKAROUND_REQUIRE_PROPAGATION
  h2->require_tag = PTR2UV(xsh_dup_inc(INT2PTR(SV *, h1->require_tag), ud->params));
 # endif
@@ -268,7 +269,7 @@ static SV *xsh_hints_tag(pTHX_ XSH_HINTS_TYPE_VAL val) {
   return newSVuv(0);
 
 #if XSH_HINTS_NEED_STRUCT
h              = PerlMemShared_malloc(sizeof *h);
XSH_SHARED_ALLOC(h, 1, xsh_hints_t);
 # if XSH_WORKAROUND_REQUIRE_PROPAGATION
  h->require_tag = xsh_require_tag();
 # endif