Changeset 1178 in MondoRescue for branches/stable/mondo/src/lib


Ignore:
Timestamp:
Feb 17, 2007, 2:27:26 AM (17 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

Location:
branches/stable/mondo/src/lib
Files:
2 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}
  • branches/stable/mondo/src/lib/mr_str.c

    r1168 r1178  
    122122 * @param in_out The string to strip spaces/control characters from (modified).
    123123 */
    124 void mr_strip_spaces(char *in_out)
    125 {
    126     /*@ int ******************************************************** */
     124void mr_strip_spaces(char *in_out) {
    127125    int i;
    128126    int j;
    129127    size_t length;
    130 
    131     /*@ end vars *************************************************** */
    132128
    133129    if (in_out == NULL) {
Note: See TracChangeset for help on using the changeset viewer.