]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - Valgrind.xs
Make the stack trace test of t/20-bad.t more predictable
[perl/modules/Test-Valgrind.git] / Valgrind.xs
1 /* This file is part of the Scalar::Vec::Util Perl module.
2  * See http://search.cpan.org/dist/Scalar-Vec-Util/ */
3
4 #define PERL_NO_GET_CONTEXT
5 #include "EXTERN.h"
6 #include "perl.h"
7 #include "XSUB.h"
8
9 #define __PACKAGE__ "Test::Valgrind"
10
11 #ifndef Newx
12 # define Newx(v, n, c) New(0, v, n, c)
13 #endif
14
15 #ifndef DEBUGGING
16 # define DEBUGGING 0
17 #endif
18
19 const char *tv_leaky = NULL;
20
21 extern void tv_leak(void) {
22  tv_leaky = malloc(10000);
23
24  return;
25 }
26
27 /* --- XS ------------------------------------------------------------------ */
28
29 MODULE = Test::Valgrind            PACKAGE = Test::Valgrind
30
31 PROTOTYPES: DISABLE
32
33 BOOT:
34 {
35  HV *stash = gv_stashpv(__PACKAGE__, 1);
36  newCONSTSUB(stash, "DEBUGGING", newSVuv(DEBUGGING));
37 }
38
39 void
40 leak()
41 CODE:
42  tv_leak();
43  XSRETURN_UNDEF;
44
45 SV *
46 notleak(SV *sv)
47 CODE:
48  Newx(tv_leaky, 10000, char);
49  Safefree(tv_leaky);
50  RETVAL = newSVsv(sv);
51 OUTPUT:
52  RETVAL