Last change
on this file since 3852 was 2334, checked in by Bruno Cornec, 15 years ago |
r3369@localhost: bruno | 2009-08-18 16:57:27 +0200
- Transform bout 100 strcpy in dyn. allocation. Quality is improving
- function figure_out_kernel_path_interactively_if_necessary now return a dynamically allocated string
- mondoarchive checked with valgrind in text an newt modes
|
-
Property svn:eol-style
set to
native
|
File size:
706 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.