summaryrefslogtreecommitdiff
path: root/other/wrez/lookup-example/shared-library.c
blob: 1f06409ffdc225115ebf1b768dce5fdc2a6ca4bd (plain)
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

#include <stdio.h>
#include <stdlib.h>


int
myshareddeepfunc (int cow);


void *
mysharedfunc (unsigned int size)
{
	void *	foo;


	fprintf (stderr, "mysharedfunc\n");

	foo = malloc (size);
	fprintf (stderr, "  # called malloc\n");
	
	free (foo);
	fprintf (stderr, "  # called free\n");

	foo = malloc (10 * size);
	fprintf (stderr, "  # called malloc\n");

	free (foo);
	fprintf (stderr, "  # called free\n");

	/* example for deep call */
	if (myshareddeepfunc (size / 2) == size)
		return ((void *) 0);

	return (foo);
}


int
myshareddeepfunc (int cow)
{
	return (cow / 2);
}