X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Valgrind.xs;fp=Valgrind.xs;h=d50485687c63664ffe54b449f9dbf9441c115443;hb=8d66aa098b18f8c9724b12bf446d330905122c57;hp=0000000000000000000000000000000000000000;hpb=4c46bbd0856ded38b0cefbabc61dc53b85025d42;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/Valgrind.xs b/Valgrind.xs new file mode 100644 index 0000000..d504856 --- /dev/null +++ b/Valgrind.xs @@ -0,0 +1,46 @@ +/* This file is part of the Scalar::Vec::Util Perl module. + * See http://search.cpan.org/dist/Scalar-Vec-Util/ */ + +#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 *tvtxs_leaky = NULL; + +/* --- XS ------------------------------------------------------------------ */ + +MODULE = Test::Valgrind PACKAGE = Test::Valgrind + +PROTOTYPES: DISABLE + +BOOT: +{ + HV *stash = gv_stashpv(__PACKAGE__, 1); + newCONSTSUB(stash, "DEBUGGING", newSVuv(DEBUGGING)); +} + +void +leak() +CODE: + Newx(tvtxs_leaky, 10000, char); + XSRETURN_UNDEF; + +SV * +notleak(SV *sv) +CODE: + Newx(tvtxs_leaky, 10000, char); + Safefree(tvtxs_leaky); + RETVAL = newSVsv(sv); +OUTPUT: + RETVAL