line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::C::FFI; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
446201
|
use strict; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
375
|
|
4
|
11
|
|
|
11
|
|
62
|
use warnings; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
322
|
|
5
|
11
|
|
|
11
|
|
3209
|
use FFI::Platypus 1.24; |
|
11
|
|
|
|
|
30967
|
|
|
11
|
|
|
|
|
256
|
|
6
|
11
|
|
|
11
|
|
93
|
use constant (); |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
252
|
|
7
|
11
|
|
|
11
|
|
55
|
use base qw( Exporter ); |
|
11
|
|
|
|
|
87
|
|
|
11
|
|
|
|
|
2375
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Private module for FFI::C |
10
|
|
|
|
|
|
|
our $VERSION = '0.14'; # 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__ |