File: domtake.c

package info (click to toggle)
ion 3.2.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,768 kB
  • ctags: 11,049
  • sloc: ansic: 141,798; sh: 22,848; makefile: 7,818; python: 1,638; sql: 311; perl: 197; awk: 178; xml: 50; java: 19
file content (31 lines) | stat: -rw-r--r-- 694 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
/*

	issue-260-teach-valgrind-mtake/domtake.c:	MTAKE-in-valgrind test.
	
	This test does some MTAKEing and MRELEASEing; you should run it from
	inside of valgrind and observe some leaks.

									*/

#include <ion.h>
#include "check.h"
#include "testutil.h"

int main(int argc, char **argv)
{
	char *stringToLeak = NULL;
	char *stringToNotLeak = NULL;

    ionAttach();

	stringToLeak = MTAKE(128);
	fail_unless(stringToLeak != NULL);
	istrcpy(stringToLeak, "This is a string we will leak on purpose.", 128);

	stringToNotLeak = MTAKE(129);
	fail_unless(stringToNotLeak != NULL);
	istrcpy(stringToNotLeak, "This is a string we won't leak.", 129);
	MRELEASE(stringToNotLeak);

	CHECK_FINISH;
}