Changeset 1196 in MondoRescue for branches/stable/mondo/src/lib
- Timestamp:
- Feb 21, 2007, 2:40:49 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/lib/mr_mem.c
r1178 r1196 114 114 * Equivalent function of strcat but safe 115 115 * from memory allocation point of view 116 * and richer from an interface point of view 116 117 */ 117 void mr_strcat_int(char **in, const char *add, int line, char *file) { 118 char *p =NULL; 118 void mr_strcat_int(char **in, int line, const char *file, const char *fmt, ...) { 119 char *p = NULL; 120 char *fmt2 = NULL; 121 va_list args; 122 int res = 0; 119 123 120 if ( add== NULL) {124 if (fmt == NULL) { 121 125 return; 122 126 } 123 127 if (in == NULL) { 124 mr_msg_int(1,line,file,"Unable to add %s to NULL pointer\nExiting...", add);128 mr_msg_int(1,line,file,"Unable to add to NULL pointer\nExiting..."); 125 129 mr_exit(-1, "Unable to add to a NULL pointer"); 126 130 } 131 va_start(args,fmt); 127 132 if (*in == NULL) { 128 mr_asprintf_int(&p,line,file,add); 133 res = vasprintf(in, fmt, args); 134 if (res == -1) { 135 mr_msg_int(1,line,file,"Unable to alloc memory in mr_strcat\nExiting..."); 136 mr_exit(-1,"Unable to alloc memory in mr_strcat"); 137 } 129 138 } else { 130 mr_asprintf_int(&p,line,file,"%s%s",*in,add); 139 mr_asprintf_int(&fmt2, line, file, "%s%s", *in, fmt); 140 res = vasprintf(&p, fmt2, args); 141 mr_free_int((void **)&fmt2,line,file); 131 142 mr_free_int((void **)in,line,file); 143 *in = p; 132 144 } 133 *in = p;145 va_end(args); 134 146 } 147 148
Note:
See TracChangeset
for help on using the changeset viewer.