File: Valgrind.xs

package info (click to toggle)
libtest-valgrind-perl 1.19-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 416 kB
  • ctags: 228
  • sloc: perl: 2,777; makefile: 17
file content (64 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* This file is part of the Test::Valgrind Perl module.
 * See http://search.cpan.org/dist/Test::Valgrind/ */

#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#define __PACKAGE__ "Test::Valgrind"

#ifndef Newx
# define Newx(v, n, c) New(0, v, n, c)
#endif

#ifndef DEBUGGING
# define DEBUGGING 0
#endif

const char *tv_leaky = NULL;

/* malloc() on Windows needs the current interpreter. */

#ifdef PERL_IMPLICIT_SYS
# define TV_LEAK_PROTO pTHX
# define TV_LEAK_ARG   aTHX
#else
# define TV_LEAK_PROTO void
# define TV_LEAK_ARG
#endif

extern void tv_leak(TV_LEAK_PROTO);

extern void tv_leak(TV_LEAK_PROTO) {
 tv_leaky = malloc(10000);

 return;
}

/* --- XS ------------------------------------------------------------------ */

MODULE = Test::Valgrind            PACKAGE = Test::Valgrind

PROTOTYPES: DISABLE

BOOT:
{
 HV *stash = gv_stashpv(__PACKAGE__, 1);
 newCONSTSUB(stash, "DEBUGGING", newSVuv(DEBUGGING));
}

void
leak()
CODE:
 tv_leak(TV_LEAK_ARG);
 XSRETURN_UNDEF;

SV *
notleak(SV *sv)
CODE:
 Newx(tv_leaky, 10000, char);
 Safefree(tv_leaky);
 RETVAL = newSVsv(sv);
OUTPUT:
 RETVAL