#include "account.h"
#include "url.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include <lib-lib/mem.h>
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
menu->max++;
}
- mem_realloc (&AliasTable, menu->max * sizeof (ALIAS *));
+ p_realloc(&AliasTable, menu->max);
menu->data = AliasTable;
for (i = omax, aliasp = aliases; aliasp; aliasp = aliasp->next, i++) {
#include "mx.h"
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#endif
#include "sidebar.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/list.h"
{
if (state->entrylen == state->entrymax) {
/* need to allocate more space */
- mem_realloc (&state->entry,
- sizeof (struct folder_file) * (state->entrymax += 256));
- memset (&state->entry[state->entrylen], 0,
- sizeof (struct folder_file) * 256);
+ p_realloc(&state->entry, state->entrymax += 256);
+ p_clear(&state->entry[state->entrylen], 256);
if (m)
m->data = state->entry;
}
if (s != NULL) {
- (state->entry)[state->entrylen].mode = s->st_mode;
+ (state->entry)[state->entrylen].mode = s->st_mode;
(state->entry)[state->entrylen].mtime = s->st_mtime;
- (state->entry)[state->entrylen].size = s->st_size;
-
- (state->entry)[state->entrylen].st = p_new(struct stat, 1);
- memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
+ (state->entry)[state->entrylen].size = s->st_size;
+ (state->entry)[state->entrylen].st = p_dup(s, 1);
}
(state->entry)[state->entrylen].new = new;
#include "buffer.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/debug.h"
/* dynamically grows a BUFFER to accomodate s, in increments of 128 bytes.
* Always one byte bigger than necessary for the null terminator, and
* the buffer is always null-terminated */
-void mutt_buffer_add (BUFFER * buf, const char *s, size_t len)
+void mutt_buffer_add (BUFFER *buf, const char *s, size_t len)
{
size_t offset;
if (buf->dptr + len + 1 > buf->data + buf->dsize) {
offset = buf->dptr - buf->data;
buf->dsize += len < 128 ? 128 : len + 1;
- mem_realloc ((void **) &buf->data, buf->dsize);
+ p_realloc(&buf->data, buf->dsize);
buf->dptr = buf->data + offset;
}
memcpy (buf->dptr, s, len);
#include "imap.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include <string.h>
#include "charset.h"
#include "ascii.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
*tlen = ob - buf;
- mem_realloc (&buf, ob - buf + 1);
+ p_realloc(&buf, ob - buf + 1);
*t = buf;
iconv_close (cd);
#include "mutt_curses.h"
#include "mapping.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
}
else if (object == MT_COLOR_QUOTED) {
if (q_level >= ColorQuoteSize) {
- mem_realloc (&ColorQuote, (ColorQuoteSize += 2) * sizeof (int));
+ p_realloc(&ColorQuote, ColorQuoteSize += 2);
ColorQuote[ColorQuoteSize - 2] = ColorDefs[MT_COLOR_QUOTED];
ColorQuote[ColorQuoteSize - 1] = ColorDefs[MT_COLOR_QUOTED];
}
#include "buffy.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "nntp.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
if (!(WithCrypto & APPLICATION_PGP))
break;
if (idxlen == idxmax) {
- mem_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
+ p_realloc(&idx, idxmax += 5);
menu->data = idx;
}
break;
if (idxlen + numfiles >= idxmax) {
- mem_realloc (&idx,
- sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles));
+ p_realloc(&idx, idxmax += 5 + numfiles);
menu->data = idx;
}
}
if (idxlen + Context->tagged >= idxmax) {
- mem_realloc (&idx,
- sizeof (ATTACHPTR *) * (idxmax +=
- 5 + Context->tagged));
+ p_realloc(&idx, idxmax += 5 + Context->tagged);
menu->data = idx;
}
continue;
}
if (idxlen == idxmax) {
- mem_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5));
+ p_realloc(&idx, idxmax += 5);
menu->data = idx;
}
#include "mbox.h"
#include "mutt_curses.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mutt_crypt.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/debug.h"
if (!headers[x])
headers[x] = this_one;
else {
- mem_realloc (&headers[x], str_len (headers[x]) +
- str_len (this_one) + sizeof (char));
- strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
+ p_realloc(&headers[x], str_len(headers[x]) + str_len(this_one) + 1);
+ strcat(headers[x], this_one); /* __STRCAT_CHECKED__ */
p_delete(&this_one);
}
* abbreviations (curline is 0), $max_display_recips is 0 and
* while the number hasn't reached $max_display_recips yet */
else if (curline == 0 || MaxDispRecips == 0 || ++curline <= MaxDispRecips) {
- mem_realloc (&this_one,
- str_len (this_one) + str_len (buf) +
- sizeof (char));
+ p_realloc(&this_one, str_len(this_one) + str_len(buf) + 1);
strcat (this_one, buf); /* __STRCAT_CHECKED__ */
/* only for the first line which doesn't exeeds
* $max_display_recips: abbreviate it */
} else if (curline == MaxDispRecips+1) {
- mem_realloc (&this_one, str_len (this_one) + 5);
+ p_realloc(&this_one, str_len(this_one) + 5);
strcat (this_one, " ...");
}
}
if (!headers[x])
headers[x] = this_one;
else {
- mem_realloc (&headers[x], str_len (headers[x]) +
- str_len (this_one) + sizeof (char));
+ p_realloc(&headers[x], str_len(headers[x]) + str_len(this_one) + 1);
strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
p_delete(&this_one);
}
buflen = linelen + 3;
- mem_realloc (h, buflen);
+ p_realloc(h, buflen);
for (count = 0; a; a = a->next, count++) {
ADDRESS *tmp = a->next;
}
buflen += l + str_len (cbuf) + str_len (c2buf);
- mem_realloc (h, buflen);
+ p_realloc(h, buflen);
strcat (*h, cbuf); /* __STRCAT_CHECKED__ */
strcat (*h, buf); /* __STRCAT_CHECKED__ */
strcat (*h, c2buf); /* __STRCAT_CHECKED__ */
#include "recvattach.h"
#include "sort.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
err = gpgme_get_key (context, buf, &key, 0);
if (!err) {
- mem_realloc (&rset, sizeof (*rset) * (rset_n + 1));
+ p_realloc(&rset, rset_n + 1);
rset[rset_n++] = key;
}
else {
}
/* NULL terminate. */
- mem_realloc (&rset, sizeof (*rset) * (rset_n + 1));
+ p_realloc(&rset, rset_n + 1);
rset[rset_n++] = NULL;
if (context)
if (i == keymax) {
keymax += 20;
- mem_realloc (&key_table, sizeof (crypt_key_t *) * keymax);
+ p_realloc(&key_table, keymax);
}
key_table[i++] = k;
#endif
keylist_size += str_len (s) + 4 + 1;
- mem_realloc (&keylist, keylist_size);
+ p_realloc(&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s0x%s%s", /* __SPRINTF_CHECKED__ */
keylist_used ? " " : "", s, forced_valid ? "!" : "");
}
#include <lib-lib/mem.h>
#include "crypt-mod.h"
-#include "lib/mem.h"
/* A type an a variable to keep track of registered crypto modules. */
typedef struct crypt_module *crypt_module_t;
#include "mutt_crypt.h"
#include "pgp.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
-static void crypt_fetch_signatures (BODY *** signatures, BODY * a, int *n)
+static void crypt_fetch_signatures (BODY ***signatures, BODY * a, int *n)
{
if (!WithCrypto)
return;
crypt_fetch_signatures (signatures, a->parts, n);
else {
if ((*n % 5) == 0)
- mem_realloc (signatures, (*n + 6) * sizeof (BODY **));
+ p_realloc(signatures, *n + 6);
(*signatures)[(*n)++] = a;
}
#include "pager.h"
#include "mbyte.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
tmp.op = op;
if (UngetCount >= UngetBufLen)
- mem_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t));
+ p_realloc(&KeyEvent, UngetBufLen += 128);
KeyEvent[UngetCount++] = tmp;
}
#include "mutt_sasl.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mutt_curses.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
break;
bytes -= str_len (p);
if (*bufmax == *buflen)
- mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
+ p_realloc(&buf, *bufmax += 25);
buf[(*buflen)++] = str_dup (tmp);
}
if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */
- mem_realloc (&buf, sizeof (char *) * (++*bufmax));
+ p_realloc(&buf, ++*bufmax);
}
if (buf)
buf[*buflen] = NULL;
}
if (*bufmax == *buflen)
- mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
+ p_realloc(&buf, *bufmax += 25);
buf[(*buflen)++] = str_dup (tmp);
bytes = Context->hdrs[n]->content->length;
pfx);
if (*bufmax == *buflen)
- mem_realloc (&buf, sizeof (char *) * (*bufmax += 25));
+ p_realloc(&buf, *bufmax += 25);
buf[(*buflen)++] = str_dup ("\n");
}
else
else {
str_cat (tmp, sizeof (tmp), "\n");
if (buflen == bufmax)
- mem_realloc (&buf, sizeof (char *) * (bufmax += 25));
+ p_realloc(&buf, bufmax += 25);
buf[buflen++] = str_dup (tmp[1] == '~' ? tmp + 1 : tmp);
}
#include "history.h"
#include "buffy.h"
-#include "lib/mem.h"
#include <string.h>
k != (size_t) (-1) && k != (size_t) (-2); buf += k) {
if (i >= wbuflen) {
wbuflen = i + 20;
- mem_realloc (&wbuf, wbuflen * sizeof (*wbuf));
+ p_realloc(&wbuf, wbuflen);
}
wbuf[i++] = wc;
}
/* Make space for suffix */
if (state->curpos + savelen > state->wbuflen) {
state->wbuflen = state->curpos + savelen;
- mem_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t));
+ p_realloc(&state->wbuf, state->wbuflen);
}
/* Restore suffix */
}
if (!mutt_complete (buf, buflen)) {
templen = state->lastchar - i;
- mem_realloc (&tempbuf, templen * sizeof (wchar_t));
+ p_realloc(&tempbuf, templen);
}
else
BEEP ();
if (!mutt_complete (buf, buflen)) {
templen = state->lastchar;
- mem_realloc (&tempbuf, templen * sizeof (wchar_t));
+ p_realloc(&tempbuf, templen);
memcpy (tempbuf, state->wbuf, templen * sizeof (wchar_t));
}
else
else if (wc && (wc < ' ' || IsWPrint (wc))) { /* why? */
if (state->lastchar >= state->wbuflen) {
state->wbuflen = state->lastchar + 20;
- mem_realloc (&state->wbuf, state->wbuflen * sizeof (wchar_t));
+ p_realloc(&state->wbuf, state->wbuflen);
}
memmove (state->wbuf + state->curpos + 1, state->wbuf + state->curpos,
(state->lastchar - state->curpos) * sizeof (wchar_t));
#include "mutt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
/* for hexval */
#include "mime.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "attach.h"
#include "lib.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
stte->line_used += stte->buff_used;
if (stte->line_used > stte->line_max) {
stte->line_max = stte->line_used;
- mem_realloc (&stte->line, stte->line_max + 1);
+ p_realloc(&stte->line, stte->line_max + 1);
}
strcat (stte->line, stte->buffer); /* __STRCAT_CHECKED__ */
stte->line_len += stte->word_len;
if (stte->tag_level[RICH_PARAM]) {
if (stte->tag_level[RICH_COLOR]) {
if (stte->param_used + 1 >= stte->param_len)
- mem_realloc (&stte->param, (stte->param_len += STRING));
+ p_realloc(&stte->param, (stte->param_len += STRING));
stte->param[stte->param_used++] = c;
}
/* see if more space is needed (plus extra for possible rich characters) */
if (stte->buff_len < stte->buff_used + 3) {
stte->buff_len += LONG_STRING;
- mem_realloc (&stte->buffer, stte->buff_len + 1);
+ p_realloc(&stte->buffer, stte->buff_len + 1);
}
if ((!stte->tag_level[RICH_NOFILL] && ISSPACE (c)) || c == '\0') {
if (stte->buff_len < stte->buff_used + str_len (s)) {
stte->buff_len += LONG_STRING;
- mem_realloc (&stte->buffer, stte->buff_len + 1);
+ p_realloc(&stte->buffer, stte->buff_len + 1);
}
p = s;
#include "mutt.h"
-#include "lib/mem.h"
-
#define SOMEPRIME 149711
int hash_string (const unsigned char *s, int n)
#include "lib.h"
#include "md5.h"
-#include "lib/mem.h"
#include "lib/debug.h"
#if HAVE_QDBM
return;
}
- mem_realloc (ptr, siz);
+ p_realloc(ptr, siz);
}
static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off)
#include "mutt.h"
#include "history.h"
-#include "lib/mem.h"
/* global vars used for the string-history routines */
#include "compress.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
#include <lib-lib/mem.h>
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
#include "imap_private.h"
#include "auth.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
#include <lib-lib/mem.h>
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "lib/debug.h"
imap_unmunge_mbox_name (folder);
if (state->entrylen + 1 == state->entrymax) {
- mem_realloc (&state->entry,
- sizeof (struct folder_file) * (state->entrymax += 256));
- memset (state->entry + state->entrylen, 0,
- (sizeof (struct folder_file) *
- (state->entrymax - state->entrylen)));
+ p_realloc(&state->entry, state->entrymax += 256);
+ p_clear(state->entry + state->entrylen,
+ state->entrymax - state->entrylen);
}
/* render superiors as unix-standard ".." */
#include <lib-lib/mem.h>
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
* line */
do {
if (len == cmd->blen) {
- mem_realloc (&cmd->buf, cmd->blen + IMAP_CMD_BUFSIZE);
+ p_realloc(&cmd->buf, cmd->blen + IMAP_CMD_BUFSIZE);
cmd->blen = cmd->blen + IMAP_CMD_BUFSIZE;
debug_print (3, ("grew buffer to %u bytes\n", cmd->blen));
}
/* don't let one large string make cmd->buf hog memory forever */
if ((cmd->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE)) {
- mem_realloc (&cmd->buf, IMAP_CMD_BUFSIZE);
+ p_realloc(&cmd->buf, IMAP_CMD_BUFSIZE);
cmd->blen = IMAP_CMD_BUFSIZE;
debug_print (3, ("shrank buffer to %u bytes\n", cmd->blen));
}
#endif
#include "buffy.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "pgp.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mx.h"
#include "mx_imap.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "url.h"
#include "charset.h"
#include "imap_private.h"
-#include "lib/mem.h"
-
static int Index_64[128] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
if (u8len)
*u8len = p - buf;
- mem_realloc (&buf, p - buf);
+ p_realloc(&buf, p - buf);
if (u8)
*u8 = buf;
return buf;
*p++ = '\0';
if (u7len)
*u7len = p - buf;
- mem_realloc (&buf, p - buf);
+ p_realloc(&buf, p - buf);
if (u7)
*u7 = buf;
return buf;
#include "imap_private.h"
#include "mutt_ssl.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
#include "mx.h"
#include "init.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
#include "mapping.h"
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include <string.h>
#include <unistd.h>
-static inline void *xmalloc(ssize_t size) {
- void *mem;
-
- if (size <= 0)
- return NULL;
-
- mem = calloc(size, 1);
- if (!mem)
- abort();
- return mem;
-}
-
-static inline void *xrealloc(void *mem, ssize_t newsize) {
- mem = realloc(mem, newsize);
- if (!mem)
- abort();
- return mem;
-}
-
-static inline void *xmemdup(const void *src, ssize_t size) {
- return memcpy(xmalloc(size), src, size);
-}
-
-static inline void *xmemdupstr(const void *src, ssize_t len) {
- char *res = xmalloc(len + 1);
- memcpy(res, src, len);
- res[len] = '\0';
- return res;
-}
-
#define p_new(type, count) ((type *)xmalloc(sizeof(type) * (count)))
#define p_clear(p, count) ((void)memset((p), 0, sizeof(*(p)) * (count)))
#define p_dup(p, count) xmemdup((p), sizeof(*(p)) * (count))
#define p_dupstr(p, len) xmemdupstr((p), (len))
+#define p_realloc(pp, count) xrealloc((void*)(pp), sizeof(**(pp)) * (count))
#ifdef __GNUC__
# define p_delete(mem_pp) \
- ({ \
+ do { \
typeof(**(mem_pp)) **__ptr = (mem_pp); \
free(*__ptr); \
*__ptr = NULL; \
- })
+ } while(0)
#else
#endif
+static inline void *xmalloc(ssize_t size) {
+ void *mem;
+
+ if (size <= 0)
+ return NULL;
+
+ mem = calloc(size, 1);
+ if (!mem)
+ abort();
+ return mem;
+}
+
static inline void xmemfree(void **ptr) {
p_delete(ptr);
}
+static inline void xrealloc(void **ptr, ssize_t newsize) {
+ if (newsize <= 0) {
+ p_delete(ptr);
+ } else {
+ *ptr = realloc(*ptr, newsize);
+ if (!*ptr)
+ abort();
+ }
+}
+
+static inline void *xmemdup(const void *src, ssize_t size) {
+ return memcpy(xmalloc(size), src, size);
+}
+
+static inline void *xmemdupstr(const void *src, ssize_t len) {
+ char *res = memcpy(xmalloc(len + 1), src, len);
+ res[len] = '\0';
+ return res;
+}
+
#endif /* MUTT_LIB_LIB_MEM_H */
#include "lib.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/debug.h"
/* There wasn't room for the line -- increase ``s'' */
offset = *size - 1; /* overwrite the terminating 0 */
*size += STRING;
- mem_realloc (&s, *size);
+ p_realloc(&s, *size);
}
}
}
noinst_LIBRARIES = libsane.a
noinst_HEADERS = str.h exit.h intl.h list.h rx.h debug.h
-libsane_a_SOURCES = mem.h exit.c str.c list.c rx.h debug.h \
- mem.c exit.h str.h list.h rx.c debug.c intl.h
+libsane_a_SOURCES = exit.c str.c list.c rx.h debug.h \
+ exit.h str.h list.h rx.c debug.c intl.h
-include ../cflags.mk
#include "list.h"
-#include "mem.h"
#include "str.h"
list2_t* list_new (void) {
void list_push_back (list2_t** l, void* p) {
if (!*l)
*l = list_new ();
- mem_realloc (&(*l)->data, (++(*l)->length)*sizeof(void*));
+ p_realloc(&(*l)->data, ++(*l)->length);
(*l)->data[(*l)->length-1] = p;
}
void list_push_front (list2_t** l, void* p) {
if (!*l)
*l = list_new ();
- mem_realloc (&(*l)->data, (++(*l)->length)*sizeof(void*));
+ p_realloc(&(*l)->data, ++(*l)->length);
if ((*l)->length > 1)
memmove (&(*l)->data[1], &(*l)->data[0], ((*l)->length-1)*sizeof(void*));
(*l)->data[0] = p;
if (list_empty(l))
return (NULL);
p = l->data[l->length-1];
- mem_realloc (&l->data, --(l->length)*sizeof(void*));
+ p_realloc(&l->data, --(l->length));
return (p);
}
return (NULL);
p = l->data[0];
memmove (&l->data[0], &l->data[1], (--(l->length))*sizeof(void*));
- mem_realloc (&l->data, l->length*sizeof(void*));
+ p_realloc(&l->data, l->length);
return (p);
}
return (list_pop_back (l));
p = l->data[c];
memmove (&l->data[c], &l->data[c+1], (l->length-c)*sizeof(void*));
- mem_realloc (&l->data, (--(l->length))*sizeof(void*));
+ p_realloc(&l->data, --(l->length));
return (p);
}
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <stdlib.h>
-
-#include "mem.h"
-#include "exit.h"
-#include "intl.h"
-
-void _mem_realloc (void *ptr, size_t siz, int line, const char* fname) {
- void *r;
- void **p = (void **) ptr;
-
- if (siz == 0) {
- if (*p) {
- free (*p); /* __MEM_CHECKED__ */
- *p = NULL;
- }
- return;
- }
-
- if (*p)
- r = (void *) realloc (*p, siz); /* __MEM_CHECKED__ */
- else {
- /* realloc(NULL, nbytes) doesn't seem to work under SunOS 4.1.x --- __MEM_CHECKED__ */
- r = (void *) malloc (siz); /* __MEM_CHECKED__ */
- }
-
- if (!r)
- exit_fatal ("mem_realloc", _("Out of memory!"), line, fname, 1);
-
- *p = r;
-}
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-#ifndef _LIB_MEM_H
-#define _LIB_MEM_H
-
-#include <sys/types.h>
-
-void _mem_realloc (void*, size_t, int, const char*);
-#define mem_realloc(p,c) _mem_realloc(p,c,__LINE__,__FILE__)
-
-#endif /* !_LIB_MEM_H */
#include "rx.h"
-#include "mem.h"
#include "str.h"
rx_t *rx_compile (const char *s, int flags) {
#include "str.h"
-#include "mem.h"
-
char *str_dup (const char *s)
{
if (!s || !*s)
{
if (!p || !*p)
return;
- mem_realloc (p, str_len (*p) + 1);
+ p_realloc(p, str_len (*p) + 1);
}
/* convert all characters in the string to lowercase */
#include <lib-lib/mem.h>
#include "list.h"
-#include "lib/mem.h"
#include "lib/str.h"
LIST *mutt_copy_list (LIST * p) {
#include "mutt_idna.h"
#include "xterm.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "compress.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "imap.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "thread.h"
#include "hcache.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
if (i > mhs->max || !mhs->flags) {
newmax = i + 128;
- mem_realloc (&mhs->flags, sizeof (mhs->flags[0]) * (newmax + 1));
+ p_realloc(&mhs->flags, newmax + 1);
for (j = mhs->max + 1; j <= newmax; j++)
mhs->flags[j] = 0;
#include "charset.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
*err = str_dup (domain);
}
else {
- mem_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2);
+ p_realloc(&a->mailbox, str_len(user) + str_len(tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
}
continue;
if (mutt_idna_to_local (domain, &tmp, 0) == 0) {
- mem_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2);
+ p_realloc(&a->mailbox, str_len(user) + str_len(tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
}
return a->mailbox;
}
- mem_realloc (&buff, str_len (tmp) + str_len (user) + 2);
+ p_realloc(&buff, str_len(tmp) + str_len(user) + 2);
sprintf (buff, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
p_delete(&tmp);
p_delete(&user);
#include "ascii.h"
#include "enter.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "mutt_sasl.h"
#include "mutt_socket.h"
-#include "lib/mem.h"
#include "lib/debug.h"
#include <errno.h>
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mutt_curses.h"
#include "mutt_ssl.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mutt_menu.h"
#include "mutt_ssl.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "lib/rx.h"
#include "mutt_socket.h"
#include "mutt_tunnel.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
for (; l; l = l->next) {
/* If this pattern needs more matches, expand pmatch. */
if (l->nmatch > nmatch) {
- mem_realloc (&pmatch, l->nmatch * sizeof (regmatch_t));
+ p_realloc(&pmatch, l->nmatch);
nmatch = l->nmatch;
}
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/list.h"
}
if (ctx->hdrs) {
- mem_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25));
- mem_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax);
+ p_realloc(&ctx->hdrs, ctx->hdrmax += 25);
+ p_realloc(&ctx->v2r, ctx->hdrmax);
}
else {
ctx->hdrs = p_new(HEADER *, (ctx->hdrmax += 25));
#include "mx.h"
#include "mx_nntp.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "url.h"
#include "rfc1524.h"
#include "rfc2047.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "lib/debug.h"
len += *buflen;
*buflen *= 2;
line = *buf;
- mem_realloc (buf, *buflen);
+ p_realloc(buf, *buflen);
line = *buf + (*pline - line);
}
strcpy (line, data->group);
*buflen *= 2;
*pline = line;
line = *buf;
- mem_realloc (buf, *buflen);
+ p_realloc(buf, *buflen);
line = *buf + (*pline - line);
}
if (x) {
!ctx->hdrs[x]->read) {
if (data->num >= data->max) {
data->max = data->max * 2;
- mem_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY));
+ p_realloc(&data->entries, data->max);
}
data->entries[data->num].first = first;
data->entries[data->num].last = last - 1;
if (series && first <= data->lastLoaded) {
if (data->num >= data->max) {
data->max = data->max * 2;
- mem_realloc (&data->entries, data->max * sizeof (NEWSRC_ENTRY));
+ p_realloc(&data->entries, data->max);
}
data->entries[data->num].first = first;
data->entries[data->num].last = data->lastLoaded;
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "lib/debug.h"
lenbuf = 0;
}
- mem_realloc (&inbuf, lenbuf + sizeof (buf));
+ p_realloc(&inbuf, lenbuf + sizeof (buf));
}
p_delete(&inbuf);
funct (NULL, data);
if (cc->ctx->hdrs[i]->article_num == n)
return 0;
if (cc->num >= cc->max)
- mem_realloc (&cc->child, sizeof (unsigned int) * (cc->max += 25));
+ p_realloc(&cc->child, cc->max += 25);
cc->child[cc->num++] = n;
return 0;
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
/* oops... */
if (lineInfo[i].chunks) {
lineInfo[i].chunks = 0;
- mem_realloc (&(lineInfo[n].syntax), sizeof (struct syntax_t));
+ p_realloc(&(lineInfo[n].syntax), 1);
}
lineInfo[i++].type = MT_COLOR_SIGNATURE;
}
if (pmatch[0].rm_eo != pmatch[0].rm_so) {
if (!found) {
if (++(lineInfo[n].chunks) > 1)
- mem_realloc (&(lineInfo[n].syntax),
- (lineInfo[n].chunks) *
- sizeof (struct syntax_t));
+ p_realloc(&(lineInfo[n].syntax), lineInfo[n].chunks);
}
i = lineInfo[n].chunks - 1;
pmatch[0].rm_so += offset;
}
if (*last == *max) {
- mem_realloc (lineInfo, sizeof (struct line_t) * (*max += LINES));
+ p_realloc(lineInfo, *max += LINES);
for (ch = *last; ch < *max; ch++) {
memset (&((*lineInfo)[ch]), 0, sizeof (struct line_t));
(*lineInfo)[ch].type = -1;
(SearchRE, (char *) fmt + offset, 1, pmatch,
(offset ? REG_NOTBOL : 0)) == 0) {
if (++((*lineInfo)[n].search_cnt) > 1)
- mem_realloc (&((*lineInfo)[n].search),
- ((*lineInfo)[n].search_cnt) * sizeof (struct syntax_t));
+ p_realloc(&(*lineInfo)[n].search, (*lineInfo)[n].search_cnt);
else
(*lineInfo)[n].search = p_new(struct syntax_t, 1);
pmatch[0].rm_so += offset;
lineInfo[i].search_cnt = -1;
lineInfo[i].quote = NULL;
- mem_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t));
+ p_realloc(&lineInfo[i].syntax, 1);
if (SearchCompiled && lineInfo[i].search)
p_delete(&(lineInfo[i].search));
}
lineInfo[i].search_cnt = -1;
lineInfo[i].quote = NULL;
- mem_realloc (&(lineInfo[i].syntax), sizeof (struct syntax_t));
+ p_realloc(&(lineInfo[i].syntax), 1);
if (SearchCompiled && lineInfo[i].search)
p_delete(&(lineInfo[i].search));
}
#include "mutt_crypt.h"
#include "url.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
if (*linelen < offset + STRING) {
/* grow the buffer */
*linelen += STRING;
- mem_realloc (&line, *linelen);
+ p_realloc(&line, *linelen);
buf = line + offset;
}
}
#include "copy.h"
#include "mime.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "copy.h"
#include "attach.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
bypass_selection:
keylist_size += str_len (keyID) + 4;
- mem_realloc (&keylist, keylist_size);
+ p_realloc(&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", /* __SPRINTF_CHECKED__ */
keyID);
keylist_used = str_len (keylist);
#include "pgp.h"
#include "rfc822.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "pager.h"
#include "sort.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
if (i == keymax) {
keymax += 5;
- mem_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax);
+ p_realloc(&KeyTable, keymax);
}
KeyTable[i++] = a;
#include "lib.h"
#include "pgplib.h"
-#include "lib/mem.h"
-
const char *pgp_pkalgbytype (unsigned char type)
{
switch (type) {
#include "pgplib.h"
#include "pgppacket.h"
-#include "lib/mem.h"
-
#define CHUNKSIZE 1024
static unsigned char *pbuf = NULL;
#include <lib-lib/mem.h>
-#include "lib/mem.h"
#include "lib/str.h"
#include <stdio.h>
#include "mx.h"
#include "mx_pop.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "url.h"
#include "mutt_crypt.h"
#include "mutt_curses.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "lib/debug.h"
#include "md5.h"
#include "pop.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
# include "mutt_ssl.h"
#endif
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
#include "lib/str.h"
if (!pop_data->auth_list) {
pop_data->auth_list = p_new(char, strlen(line) + 1);
} else {
- mem_realloc (&pop_data->auth_list,
- strlen (pop_data->auth_list) + strlen (line) + 2);
+ p_realloc(&pop_data->auth_list,
+ strlen(pop_data->auth_list) + strlen(line) + 2);
strcat (pop_data->auth_list, " "); /* __STRCAT_CHECKED__ */
}
strcat (pop_data->auth_list, line); /* __STRCAT_CHECKED__ */
p++;
}
- strfcpy (inbuf + lenbuf, p, sizeof (buf));
+ strfcpy(inbuf + lenbuf, p, sizeof(buf));
pos += chunk;
if (chunk >= sizeof (buf)) {
lenbuf = 0;
}
- mem_realloc (&inbuf, lenbuf + sizeof (buf));
+ p_realloc(&inbuf, lenbuf + sizeof(buf));
}
p_delete(&inbuf);
#endif
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mapping.h"
#include "sort.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
int clear = 0;
/* append */
- mem_realloc (&QueryTable, menu->max * sizeof (ENTRY));
+ p_realloc(&QueryTable, menu->max);
menu->data = QueryTable;
#include "copy.h"
#include "mutt_crypt.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
for (; m; m = m->next) {
if (*idxlen == *idxmax) {
- mem_realloc (&idx, sizeof (ATTACHPTR *) * ((*idxmax) += 5));
+ p_realloc(&idx, (*idxmax) += 5);
for (i = *idxlen; i < *idxmax; i++)
idx[i] = NULL;
}
#include "copy.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "remailer.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
{
if (*used == *slots) {
*slots += 5;
- mem_realloc (type2_list, sizeof (REMAILER *) * (*slots));
+ p_realloc(type2_list, *slots);
}
(*type2_list)[(*used)++] = entry;
if (!chain->cl)
return;
- mem_realloc (coordsp, sizeof (struct coord) * chain->cl);
+ p_realloc(coordsp, chain->cl);
coords = *coordsp;
#include "rfc1524.h"
#include "attach.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
if (get_field_text (field + 4, &test_command, type, filename, line)
&& test_command) {
len = str_len (test_command) + STRING;
- mem_realloc (&test_command, len);
+ p_realloc(&test_command, len);
rfc1524_expand_command (a, a->filename, type, test_command, len);
if (mutt_system (test_command)) {
/* a non-zero exit code means test failed */
#include "rfc2047.h"
#include "thread.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include <ctype.h>
*tlen = ob - buf;
- mem_realloc (&buf, ob - buf + 1);
+ p_realloc(&buf, ob - buf + 1);
*t = buf;
iconv_close (cd);
#define LINEBREAK "\n\t"
if (bufpos + wlen + str_len (LINEBREAK) > buflen) {
buflen = bufpos + wlen + str_len (LINEBREAK);
- mem_realloc (&buf, buflen);
+ p_realloc(&buf, buflen);
}
r = encode_block (buf + bufpos, t, n, icode, tocode, encoder);
assert (r == wlen);
/* Add last encoded word and us-ascii suffix to buffer. */
buflen = bufpos + wlen + (u + ulen - t1);
- mem_realloc (&buf, buflen + 1);
+ p_realloc(&buf, buflen + 1);
r = encode_block (buf + bufpos, t, t1 - t, icode, tocode, encoder);
assert (r == wlen);
bufpos += wlen;
#include "rfc2047.h"
#include "rfc2231.h"
-#include "lib/mem.h"
-
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
vl = str_len (par->value);
- mem_realloc (&value, l + vl + 1);
+ p_realloc(&value, l + vl + 1);
strcpy (value + l, par->value); /* __STRCPY_CHECKED__ */
l += vl;
#include "state.h"
#include "lib.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
curline_len = 1;
}
- mem_realloc (&curline, curline_len + buf_len - buf_off);
+ p_realloc(&curline, curline_len + buf_len - buf_off);
strcpy (curline + curline_len - 1, buf + buf_off);
curline_len += buf_len - buf_off;
#include "ascii.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "sort.h"
#include "buffer.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include <string.h>
#include "url.h"
#include "attach.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
#include "mutt_crypt.h"
#include "mutt_idna.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "lib/debug.h"
for (; (TrimRef == 0 || refcnt < TrimRef) && r; r = r->next) {
if (refcnt == refmax)
- mem_realloc (&ref, (refmax += REF_INC) * sizeof (LIST *));
+ p_realloc(&ref, refmax += REF_INC);
ref[refcnt++] = r;
}
continue;
rfc2047_encode_string (&tmp);
- mem_realloc (&h->data,
- str_len (h->data) + 2 + str_len (tmp) + 1);
+ p_realloc(&h->data, str_len(h->data) + 2 + str_len(tmp) + 1);
sprintf (h->data + i, ": %s", NONULL (tmp)); /* __SPRINTF_CHECKED__ */
/* weed out group mailboxes, since those are for display only */
if (addr->mailbox && !addr->group) {
if (*argslen == *argsmax)
- mem_realloc (&args, (*argsmax += 5) * sizeof (char *));
+ p_realloc(&args, *argsmax += 5);
args[(*argslen)++] = addr->mailbox;
}
}
add_option(const char **args, size_t *argslen, size_t *argsmax, const char *s)
{
if (*argslen == *argsmax) {
- mem_realloc(&args, (*argsmax += 5) * sizeof (char *));
+ p_realloc(&args, *argsmax += 5);
}
args[(*argslen)++] = s;
return (args);
i = 0;
while ((ps = strtok (ps, " "))) {
if (argslen == argsmax)
- mem_realloc (&args, sizeof (char *) * (argsmax += 5));
+ p_realloc(&args, argsmax += 5);
if (i)
args[argslen++] = ps;
#endif
if (argslen == argsmax)
- mem_realloc (&args, sizeof (char *) * (++argsmax));
+ p_realloc(&args, ++argsmax);
args[argslen++] = NULL;
{
size_t la = str_len (a);
- mem_realloc (&a, la + str_len (b) + 1);
+ p_realloc(&a, la + str_len(b) + 1);
strcpy (a + la, b); /* __STRCPY_CHECKED__ */
return (a);
}
if (INVALID_CHAR (*s)) {
size_t o = pr - r;
- mem_realloc (&r, ++rlen);
+ p_realloc(&r, ++rlen);
pr = r + o;
*pr++ = '\\';
}
#include "buffy.h"
#include "keymap.h"
-#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
#include "mime.h"
#include "copy.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/debug.h"
}
keylist_size += str_len (keyID) + 2;
- mem_realloc (&keylist, keylist_size);
+ p_realloc(&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s\n", keyID); /* __SPRINTF_CHECKED__ */
keylist_used = str_len (keylist);
#include "mx.h"
#include "buffy.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "sort.h"
#include "thread.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include <string.h>
/* put them into the array */
for (i = 0; thread; i++, thread = thread->prev) {
if (i >= array_size)
- mem_realloc (&array, (array_size *= 2) * sizeof (THREAD *));
+ p_realloc(&array, array_size *= 2);
array[i] = thread;
}
#include "mime.h"
-#include "lib/mem.h"
-
#include <ctype.h>
static struct mapping_t UrlMap[] = {