--- embedaddon/mpd/src/mbuf.c 2012/02/21 23:32:47 1.1 +++ embedaddon/mpd/src/mbuf.c 2021/03/17 00:39:23 1.1.1.3 @@ -55,6 +55,20 @@ Mdup(const char *type, const void *src, size_t size) } void * +Mdup2(const char *type, const void *src, size_t oldsize, size_t newsize) +{ + const char **memory; + if ((memory = MALLOC(type, sizeof(char *) + newsize)) == NULL) { + Perror("Mdup2: malloc"); + DoExit(EX_ERRDEAD); + } + + memory[0] = type; + memcpy(memory + 1, src, oldsize < newsize ? oldsize : newsize); + return(memory + 1); +} + +void * Mstrdup(const char *type, const void *src) { return (Mdup(type, src, strlen(src) + 1)); @@ -299,7 +313,7 @@ mbsplit(Mbuf bp, int cnt) if (!bp) return (NULL); - if (MBLEN(bp) <= cnt) + if ((int)MBLEN(bp) <= cnt) return (NULL); nbp = mballoc(bp->cnt - cnt); @@ -315,12 +329,16 @@ mbsplit(Mbuf bp, int cnt) */ int -MemStat(Context ctx, int ac, char *av[], void *arg) +MemStat(Context ctx, int ac, const char *const av[], const void *arg) { struct typed_mem_stats stats; u_int i; u_int total_allocs = 0; u_int total_bytes = 0; + + (void)ac; + (void)av; + (void)arg; if (typed_mem_usage(&stats)) Error("typed_mem_usage() error");