Last change
on this file since 2326 was 2310, checked in by Bruno Cornec, 15 years ago |
Backport all test programs from trunk into 2.2.10
|
-
Property svn:eol-style
set to
native
|
File size:
707 bytes
|
Line | |
---|
1 | #include <mr_mem.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <stdlib.h>
|
---|
4 | #include <assert.h>
|
---|
5 |
|
---|
6 | void (*mr_cleanup)(void) = NULL;
|
---|
7 |
|
---|
8 | void is_null(const char* str)
|
---|
9 | {
|
---|
10 | if (str == NULL)
|
---|
11 | printf("pointer is null\n");
|
---|
12 | else
|
---|
13 | printf("pointer is NOT null\n");
|
---|
14 | }
|
---|
15 |
|
---|
16 | int main(void)
|
---|
17 | {
|
---|
18 | char* str = NULL;
|
---|
19 |
|
---|
20 | printf("*** Test with mr_free\n");
|
---|
21 | str = mr_malloc(10);
|
---|
22 | is_null(str);
|
---|
23 | mr_free(str);
|
---|
24 | is_null(str);
|
---|
25 |
|
---|
26 | printf("*** Test with NULL\n");
|
---|
27 | str = NULL;
|
---|
28 | is_null(str);
|
---|
29 | mr_free(str);
|
---|
30 | is_null(str);
|
---|
31 |
|
---|
32 | mr_asprintf(&str, "%s is %d", "two", 2);
|
---|
33 | printf("*** String is %s\n",str);
|
---|
34 |
|
---|
35 | /* Cating other content */
|
---|
36 | mr_strcat(str," But %s is %d", "three", 3);
|
---|
37 | printf("*** String is now %s\n",str);
|
---|
38 |
|
---|
39 | exit(0);
|
---|
40 | }
|
---|
41 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.