line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::C::FFI; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
462176
|
use strict; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
338
|
|
4
|
11
|
|
|
11
|
|
52
|
use warnings; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
304
|
|
5
|
11
|
|
|
11
|
|
3167
|
use FFI::Platypus 1.24; |
|
11
|
|
|
|
|
31359
|
|
|
11
|
|
|
|
|
262
|
|
6
|
11
|
|
|
11
|
|
81
|
use constant (); |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
239
|
|
7
|
11
|
|
|
11
|
|
53
|
use base qw( Exporter ); |
|
11
|
|
|
|
|
65
|
|
|
11
|
|
|
|
|
2433
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Private module for FFI::C |
10
|
|
|
|
|
|
|
our $VERSION = '0.15'; # 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__ |