Devel.xs

filter: Statementstmt 61.9% 13 / 21 Branchbran 38.8% 7 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 51.2% 20 / 39 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« Av_CharPtrPtr.c ↑ Summary xpath.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 #include "ppport.h"
24  
25 #include <stdlib.h>
26  
27 /* XML::LibXML stuff */
28 #include <libxml/xmlmemory.h>
29 #include "perl-libxml-mm.h"
30  
31 #undef NDEBUG
32 #include <assert.h>
33  
34 0 static void * xmlMemMallocAtomic(size_t size)
35 {
36 0 return xmlMallocAtomicLoc(size, "none", 0);
37 }
38  
39 1 static int debug_memory()
40 {
41 1 return xmlGcMemSetup( xmlMemFree,
42 xmlMemMalloc,
43 xmlMemMallocAtomic,
44 xmlMemRealloc,
45 xmlMemStrdup);
46 }
47  
48 MODULE = XML::LibXML::Devel PACKAGE = XML::LibXML::Devel
49  
50 PROTOTYPES: DISABLE
51  
52 BOOT:
53 69 ▶ if (getenv("DEBUG_MEMORY")) {
Branch: 1 branch
BranchTrueFalseTotal
if (getenv("DEBUG_MEMORY")) { 1 68 69
54 1 debug_memory();
55 }
56  
57  
58  
59 SV*
60 node_to_perl( n, o = NULL )
61 void * n
62 void * o
63 PREINIT:
64 0 xmlNode *node = n;
65 0 ▶ xmlNode *owner = o;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *owner = o; 0 0 0
66 CODE:
67 0 ▶ RETVAL = PmmNodeToSv(node , owner?owner->_private:NULL );
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PmmNodeToSv(node , owner?owner->_private:NULL ); 0 0 0
68 OUTPUT:
69 RETVAL
70  
71 void *
72 node_from_perl( sv )
73 SV *sv
74 PREINIT:
75 6 xmlNode *n = PmmSvNodeExt(sv, 0);
76 CODE:
77 6 ▶ RETVAL = n;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = n; 0 6 6
78 OUTPUT:
79 RETVAL
80  
81 void
82 refcnt_inc( n )
83 void *n
84 PREINIT:
85 4 xmlNode *node = n;
86 CODE:
87 4 ▶ PmmREFCNT_inc(((ProxyNode *)(node->_private)));
Branch: 1 branch
BranchTrueFalseTotal
PmmREFCNT_inc(((ProxyNode *)(node->_private))); 0 4 4
88  
89 int
90 refcnt_dec( n )
91 void *n
92 PREINIT:
93 4 ▶ xmlNode *node = n;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *node = n; 4 0 4
94 CODE:
95 4 RETVAL = PmmREFCNT_dec(((ProxyNode *)(node->_private)));
96 OUTPUT:
97 RETVAL
98  
99 int
100 refcnt( n )
101 void *n
102 PREINIT:
103 8 ▶ xmlNode *node = n;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *node = n; 8 0 8
104 CODE:
105 8 ▶ RETVAL = PmmREFCNT(((ProxyNode *)(node->_private)));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PmmREFCNT(((ProxyNode *)(node->_private))); 0 8 8
106 OUTPUT:
107 RETVAL
108  
109 int
110 fix_owner( n, p )
111 void * n
112 void * p
113 PREINIT:
114 0 xmlNode *node = n;
115 0 ▶ xmlNode *parent = p;
Branch: 1 branch
BranchTrueFalseTotal
xmlNode *parent = p; 0 0 0
116 CODE:
117 0 RETVAL = PmmFixOwner(node->_private , parent->_private);
118 OUTPUT:
119 RETVAL
120  
121 int
122 mem_used()
123 CODE:
124 9 RETVAL = xmlMemUsed();
125 OUTPUT:
126 RETVAL
127  
128  
« Av_CharPtrPtr.c ↑ Summary xpath.c »