Ignore:
Timestamp:
Feb 17, 2007, 2:27:26 AM (13 years ago)
Author:
Bruno Cornec
Message:

Continue to merge trunk memory management enhancements for libmondo-tools.c & libmondo-string.c
Introduction + test of a new function mr_strcat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/lib/mr_mem.c

    r1174 r1178  
    110110    }
    111111}
     112
     113/*
     114 * Equivalent function of strcat but safe
     115 * from memory allocation point of view
     116 */
     117void mr_strcat_int(char **in, const char *add, int line, char *file) {
     118    char *p =NULL;
     119   
     120    if (add == NULL) {
     121        return;
     122    }
     123    if (in == NULL) {
     124        mr_msg_int(1,line,file,"Unable to add %s to NULL pointer\nExiting...", add);
     125        mr_exit(-1, "Unable to add to a NULL pointer");
     126    }
     127    if (*in == NULL) {
     128        mr_asprintf_int(&p,line,file,add);
     129    } else {
     130        mr_asprintf_int(&p,line,file,"%s%s",*in,add);
     131        mr_free_int((void **)in,line,file);
     132    }
     133    *in = p;
     134}
Note: See TracChangeset for help on using the changeset viewer.