Devel.xs

filter: Statementstmt 0.0% 0 / 14 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 30 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/XML/LibXML/Boolean.pm ↑ Summary Av_CharPtrPtr.c »
1 /* $Id: Devel.xs 20 2011-10-11 02:05:01Z jo $
2 *
3 * This is free software, you may use it and distribute it under the same terms as
4 * Perl itself.
5 *
6 * Copyright 2011 Joachim Zobel
7 *
8 * This module gives external access to the functions needed to create
9 * and use XML::LibXML::Nodes from C functions. These functions are made
10 * accessible from Perl to have cleaner dependencies.
11 * The idea is to pass xmlNode * pointers (as typemapped void *) to and
12 * from Perl and call the functions that turns them to and from
13 * XML::LibXML::Nodes there.
14 *
15 * Be aware that using this module gives you the ability to easily create
16 * segfaults and memory leaks.
17 */
18  
19 #include "EXTERN.h"
20 #include "perl.h"
21 #include "XSUB.h"
22  
23  
24 #include <stdlib.h>
25  
26 /* XML::LibXML stuff */
27 #include <libxml/xmlmemory.h>
28 #include "perl-libxml-mm.h"
29  
30 #undef NDEBUG
31 #include <assert.h>
32  
33 /* libxml2's custom memory-allocator and tracking API was removed in 2.14.
34 * Apple SDKs (macOS 15.4 / iOS 18.4 / etc.) pre-flag it as deprecated even
35 * while shipping libxml2 < 2.14. Only expose debug_memory() and mem_used()
36 * when the API is genuinely supported by the installed libxml2. */
37 #if LIBXML_VERSION < 21400 && !defined(LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS)
38 #define HAVE_LIBXML_MEMORY_DEBUG 1
39 #endif
40  
41 #ifdef HAVE_LIBXML_MEMORY_DEBUG
42 static void * xmlMemMallocAtomic(size_t size)
43 {
44 return xmlMallocAtomicLoc(size, "none", 0);
45 }
46  
47 static int debug_memory()
48 {
49 return xmlGcMemSetup( xmlMemFree,
50 xmlMemMalloc,
51 xmlMemMallocAtomic,
52 xmlMemRealloc,
53 xmlMemStrdup);
54 }
55 #endif
56  
57 MODULE = XML::LibXML::Devel PACKAGE = XML::LibXML::Devel
58  
59 PROTOTYPES: DISABLE
60  
61 BOOT:
62 #ifdef HAVE_LIBXML_MEMORY_DEBUG
63 if (getenv("DEBUG_MEMORY")) {
64 debug_memory();
65 }
66 #endif
67  
68  
69  
70 SV*
71 node_to_perl( n, o = NULL )
72 void * n
73 void * o
74 PREINIT:
75 0 xmlNode *node = n;
76 0 ▶ xmlNode *owner = o;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *owner = o; 0 0 0
77 CODE:
78 0 ▶ RETVAL = PmmNodeToSv(node , owner?owner->_private:NULL );
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PmmNodeToSv(node , owner?owner->_private:NULL ); 0 0 0
79 OUTPUT:
80 RETVAL
81  
82 void *
83 node_from_perl( sv )
84 SV *sv
85 PREINIT:
86 0 xmlNode *n = PmmSvNodeExt(sv, 0);
87 CODE:
88 0 ▶ RETVAL = n;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = n; 0 0 0
89 OUTPUT:
90 RETVAL
91  
92 void
93 refcnt_inc( n )
94 void *n
95 PREINIT:
96 0 xmlNode *node = n;
97 CODE:
98 0 ▶ PmmREFCNT_inc(((ProxyNode *)(node->_private)));
Branch: 1 branch
BranchTrueFalseTotal
PmmREFCNT_inc(((ProxyNode *)(node->_private))); 0 0 0
99  
100 int
101 refcnt_dec( n )
102 void *n
103 PREINIT:
104 0 ▶ xmlNode *node = n;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *node = n; 0 0 0
105 CODE:
106 0 RETVAL = PmmREFCNT_dec(((ProxyNode *)(node->_private)));
107 OUTPUT:
108 RETVAL
109  
110 int
111 refcnt( n )
112 void *n
113 PREINIT:
114 0 ▶ xmlNode *node = n;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *node = n; 0 0 0
115 CODE:
116 0 ▶ RETVAL = PmmREFCNT(((ProxyNode *)(node->_private)));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PmmREFCNT(((ProxyNode *)(node->_private))); 0 0 0
117 OUTPUT:
118 RETVAL
119  
120 int
121 fix_owner( n, p )
122 void * n
123 void * p
124 PREINIT:
125 0 xmlNode *node = n;
126 0 ▶ xmlNode *parent = p;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *parent = p; 0 0 0
127 CODE:
128 0 RETVAL = PmmFixOwner(node->_private , parent->_private);
129 OUTPUT:
130 RETVAL
131  
132 #ifdef HAVE_LIBXML_MEMORY_DEBUG
133  
134 int
135 mem_used()
136 CODE:
137 RETVAL = xmlMemUsed();
138 OUTPUT:
139 RETVAL
140  
141 #endif
142  
143  
« blib/lib/XML/LibXML/Boolean.pm ↑ Summary Av_CharPtrPtr.c »