| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| #include "ppport.h" |
| 6 |
|
| |
| 7 |
|
| /* C functions */ |
| 8 |
|
| int |
| 9 |
1 |
| use_var_len_array(int size) |
| 10 |
1 |
| { |
| 11 |
1 |
| int array[size]; |
| 12 |
|
| int i; |
| 13 |
|
| |
| 14 |
11 |
▶ | for(i=0; i< size; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for(i=0; i< size; ++i) { |
10 |
1 |
11 |
|
| 15 |
10 |
| array[i] = (i*2)+1; |
| 16 |
|
| } |
| 17 |
|
| |
| 18 |
1 |
| return array[size/2]; |
| 19 |
|
| } |
| 20 |
|
| |
| 21 |
|
| MODULE = Devel::CCompat::C99::VariableLengthArrays PACKAGE = Devel::CCompat::C99::VariableLengthArrays |
| 22 |
|
| PROTOTYPES: DISABLE |
| 23 |
|
| |
| 24 |
|
| # XS code |
| 25 |
|
| |
| 26 |
|
| int |
| 27 |
|
| create_array(int size) |
| 28 |
|
| CODE: |
| 29 |
1 |
▶ | if(size <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(size <= 0) { |
0 |
1 |
1 |
|
| 30 |
0 |
| croak("size must be positive\n"); |
| 31 |
|
| } |
| 32 |
1 |
| RETVAL = use_var_len_array(size); |
| 33 |
|
| OUTPUT: RETVAL |
| 34 |
|
| |