- Timestamp:
- Mar 5, 2024, 2:51:50 AM (4 months ago)
- Location:
- branches/3.3/mondo/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/include/mr_mem.h
r3708 r3837 19 19 20 20 #define mr_free(x) mr_free_int((void **)&x,__LINE__,__FILE__) 21 #define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__)22 21 #define mr_asprintf(x,y,args...) mr_asprintf_int((char **)&x,__LINE__,__FILE__,y,## args) 23 22 #define mr_getline(x,y) mr_getline_int((char **)&x,y,__LINE__,__FILE__) … … 29 28 * called indirectly through macros */ 30 29 MR_EXTERN void mr_free_int(void **allocated, int line, char *file); 31 MR_EXTERN void mr_allocstr_int(char *alloc, const char *orig, int line, char *file);32 30 MR_EXTERN void mr_asprintf_int(char **alloc, int line, char *file, const char *fmt, ...); 33 31 MR_EXTERN void mr_getline_int(char **lineptr, FILE *stream, int line, char *file); -
branches/3.3/mondo/src/lib/mr_mem.c
r3645 r3837 53 53 } 54 54 55 /* encapsulation function for asprintf */ 55 /* 56 * Function that properly allocates a string from a format and params by encapsulating asprintf 57 * freeing it before in any case 58 */ 56 59 void mr_asprintf_int(char **strp, int line, const char *file, const char *fmt, ...) { 57 60 58 61 int res = 0; 59 62 va_list args; 63 64 if ((strp != NULL) && (*strp != NULL)) { 65 mr_free_int((void **)strp, line, file); 66 } 60 67 61 68 va_start(args,fmt); … … 89 96 mr_asprintf_int(lineptr,line,file,""); 90 97 } 91 }92 93 /*94 * Function that properly allocates a string from another one95 * freeing it before in any case96 */97 void mr_allocstr_int(char *alloc, const char *orig, int line, const char *file) {98 99 if (alloc != NULL) {100 mr_free_int((void **)&alloc, line, file);101 }102 mr_asprintf_int(&alloc, line, file, orig);103 98 } 104 99
Note:
See TracChangeset
for help on using the changeset viewer.