Changeset 1139 in MondoRescue for branches/stable/mondo/src/test/test-mem.c
- Timestamp:
- Feb 11, 2007, 7:04:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/test/test-mem.c
r1105 r1139 1 #include <mr_mem.h>2 1 #include <stdio.h> 3 2 #include <stdlib.h> 4 3 #include <assert.h> 5 4 5 #include "mr_mem.h" 6 #include "mr_file.h" 7 6 8 void is_null(const char* str) 7 9 { 8 9 10 11 10 if (str == NULL) 11 printf("pointer is null\n"); 12 else 13 printf("pointer is NOT null\n"); 12 14 } 13 15 14 16 int main(void) 15 17 { 16 char* str = NULL; 18 char* str = NULL; 19 FILE *fd = NULL; 20 size_t n = 0; 17 21 18 printf("*** Test withmr_free\n");19 20 21 22 22 printf("*** Test with mr_malloc/mr_free\n"); 23 str = mr_malloc(10); 24 is_null(str); 25 mr_free(str); 26 is_null(str); 23 27 24 printf("*** Test with NULL\n"); 25 str = NULL; 26 is_null(str); 27 mr_free(str); 28 is_null(str); 28 printf("*** Test with mr_asprintf/mr_free\n"); 29 mr_asprintf(&str,"Chain %s","of trust"); 30 printf("Result: %s\n",str); 31 mr_free(str); 29 32 30 return 0; 33 printf("*** Test with mr_getline/mr_free\n"); 34 fd = mr_fopen("/etc/passwd","r"); 35 mr_getline(&str,&n,fd); 36 printf("1st Result: %s",str); 37 mr_getline(&str,&n,fd); 38 printf("2nd Result: %s",str); 39 mr_free(str); 40 41 printf("*** Test with NULL\n"); 42 str = NULL; 43 is_null(str); 44 mr_free(str); 45 is_null(str); 46 47 return 0; 31 48 } 32 49
Note:
See TracChangeset
for help on using the changeset viewer.