line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::C::FFI; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
368257
|
use strict; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
274
|
|
4
|
11
|
|
|
11
|
|
48
|
use warnings; |
|
11
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
262
|
|
5
|
11
|
|
|
11
|
|
2380
|
use FFI::Platypus 1.24; |
|
11
|
|
|
|
|
26071
|
|
|
11
|
|
|
|
|
244
|
|
6
|
11
|
|
|
11
|
|
70
|
use constant (); |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
192
|
|
7
|
11
|
|
|
11
|
|
43
|
use base qw( Exporter ); |
|
11
|
|
|
|
|
59
|
|
|
11
|
|
|
|
|
2419
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Private module for FFI::C |
10
|
|
|
|
|
|
|
our $VERSION = '0.12'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( malloc free memset memcpy_addr ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $ffi = FFI::Platypus->new( api => 1, lib => [undef] ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
constant->import( memcpy_addr => $ffi->find_symbol( 'memcpy' ) ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$ffi->attach( malloc => ['size_t'] => 'opaque', '$' ); |
20
|
|
|
|
|
|
|
$ffi->attach( free => ['opaque'] => 'void', '$' ); |
21
|
|
|
|
|
|
|
$ffi->attach( memset => ['opaque','int','size_t'] => 'opaque', '$$$' ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
## should this be configurable for when we hunt for memory leaks? |
24
|
|
|
|
|
|
|
#sub malloc ($) |
25
|
|
|
|
|
|
|
#{ |
26
|
|
|
|
|
|
|
# $ffi->function( malloc => ['size_t'] => 'opaque' ) |
27
|
|
|
|
|
|
|
# ->call(@_); |
28
|
|
|
|
|
|
|
#} |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
#sub free ($) |
31
|
|
|
|
|
|
|
#{ |
32
|
|
|
|
|
|
|
# $ffi->function( free => ['opaque'] => 'void' ) |
33
|
|
|
|
|
|
|
# ->call(@_); |
34
|
|
|
|
|
|
|
#} |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
#sub memset ($$$) |
37
|
|
|
|
|
|
|
#{ |
38
|
|
|
|
|
|
|
# $ffi->function( memset => ['opaque','int','size_t'] => 'opaque' ) |
39
|
|
|
|
|
|
|
# ->call(@_); |
40
|
|
|
|
|
|
|
#} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |