Annotation of libaitsess/contrib/test_mem.c, revision 1.1.2.5
1.1.2.1 misho 1: #include <stdio.h>
2: #include <aitsess.h>
3:
4:
5: int
6: main(int argc, char **argv)
7: {
8: mpool_t *mp;
1.1.2.2 misho 9: void *addr;
10: int i;
11:
1.1.2.3 misho 12: for (i = 0; i < 3; i++) {
13: addr = malloc(4000);
14: printf("addr=%p\n", addr);
15: free(addr);
16: }
1.1.2.1 misho 17:
1.1.2.5 ! misho 18: mp = mpool_init(0);
1.1.2.1 misho 19: if (!mp) {
20: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
21: return 1;
22: }
23:
1.1.2.2 misho 24: for (i = 0; i < 3; i++) {
1.1.2.4 misho 25: addr = mpool_malloc(mp, 4000, "mdaaa 4000");
26: if (!addr) {
27: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
28: mpool_destroy(&mp);
29: return 2;
30: }
31: printf("addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));
32:
33: strlcpy(addr, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ndddddd\n",
34: mpool_getsizebyaddr(addr));
35: // mpool_free(mp, addr, 0);
36: }
37:
38: mpool_free(mp, addr, 0);
39:
40: mpool_purge(mp, 0);
41:
1.1.2.2 misho 42: addr = mpool_malloc(mp, 4000, "mdaaa 4000");
43: if (!addr) {
44: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
45: mpool_destroy(&mp);
46: return 2;
47: }
48: printf("addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));
1.1.2.3 misho 49: mpool_free(mp, addr, 0);
1.1.2.2 misho 50:
1.1.2.1 misho 51: mpool_destroy(&mp);
52: return 0;
53: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>