Changeset 3837 in MondoRescue for branches


Ignore:
Timestamp:
Mar 5, 2024, 2:51:50 AM (4 months ago)
Author:
Bruno Cornec
Message:

integrates mr_allocstr_int functions not used yet into mr_asprintf_int

Location:
branches/3.3/mondo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/include/mr_mem.h

    r3708 r3837  
    1919
    2020#define mr_free(x) mr_free_int((void **)&x,__LINE__,__FILE__)
    21 #define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__)
    2221#define mr_asprintf(x,y,args...) mr_asprintf_int((char **)&x,__LINE__,__FILE__,y,## args)
    2322#define mr_getline(x,y) mr_getline_int((char **)&x,y,__LINE__,__FILE__)
     
    2928 * called indirectly through macros */
    3029MR_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);
    3230MR_EXTERN void mr_asprintf_int(char **alloc, int line, char *file, const char *fmt, ...);
    3331MR_EXTERN void mr_getline_int(char **lineptr, FILE *stream, int line, char *file);
  • branches/3.3/mondo/src/lib/mr_mem.c

    r3645 r3837  
    5353}
    5454
    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 */
    5659void mr_asprintf_int(char **strp, int line, const char *file, const char *fmt, ...) {
    5760
    5861    int res = 0;
    5962    va_list args;
     63
     64    if ((strp != NULL) && (*strp != NULL)) {
     65        mr_free_int((void **)strp, line, file);
     66    }
    6067
    6168    va_start(args,fmt);
     
    8996        mr_asprintf_int(lineptr,line,file,"");
    9097    }
    91 }
    92 
    93 /*
    94  * Function that properly allocates a string from another one
    95  * freeing it before in any case
    96  */
    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);
    10398}
    10499
Note: See TracChangeset for help on using the changeset viewer.