summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <juyung.seo@samsung.com>2015-02-10 15:24:01 +0900
committerDaniel Juyung Seo <juyung.seo@samsung.com>2015-02-10 15:24:01 +0900
commit26ed01c438e960f3f6b68449473ee6622fc73ae4 (patch)
tree4a05d4619d061528b7bf072046f8e7c53135298d
parente098f575b896a097102ffd0fe19f1495c09bbac6 (diff)
misc: Add memory leak example.
-rw-r--r--misc/memory_leak.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/misc/memory_leak.c b/misc/memory_leak.c
new file mode 100644
index 0000000..fead107
--- /dev/null
+++ b/misc/memory_leak.c
@@ -0,0 +1,27 @@
1#include <stdlib.h>
2
3typedef struct _sang {
4 int a[100];
5 int b[200];
6 int c[300];
7} Sang;
8
9typedef struct _ho {
10 int a[100];
11} Ho;
12
13int main(void)
14{
15 int i = 0;
16 Sang *sang = NULL;
17 Ho *ho = NULL;
18
19 for (i = 0; i < 100000; i++)
20 {
21 sang = (Sang *)malloc(sizeof(Sang));
22 ho = (Ho *)sang; // this works fine
23 //free(ho);
24 }
25
26 return 0;
27}