Ignore:
Timestamp:
Feb 21, 2007, 2:40:49 AM (12 years ago)
Author:
bruno
Message:

ChangeLog? for mindi UTF-8
mr_strcat much more powerful as taking a vararg (+ tests).
improved text output to log file for mondo
merge from trunk memory management for mondorestore (begining)

File:
1 edited

Legend:

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

    r1178 r1196  
    114114 * Equivalent function of strcat but safe
    115115 * from memory allocation point of view
     116 * and richer from an interface point of view
    116117 */
    117 void mr_strcat_int(char **in, const char *add, int line, char *file) {
    118     char *p =NULL;
     118void 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;
    119123   
    120     if (add == NULL) {
     124    if (fmt == NULL) {
    121125        return;
    122126    }
    123127    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...");
    125129        mr_exit(-1, "Unable to add to a NULL pointer");
    126130    }
     131    va_start(args,fmt);
    127132    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        }
    129138    } 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);
    131142        mr_free_int((void **)in,line,file);
     143        *in = p;
    132144    }
    133     *in = p;
     145    va_end(args);
    134146}
     147
     148
Note: See TracChangeset for help on using the changeset viewer.