[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nmh-commits] nmh ./ChangeLog sbr/Makefile.in sbr/add.c sbr/b...
From: |
Josh Bressers |
Subject: |
[Nmh-commits] nmh ./ChangeLog sbr/Makefile.in sbr/add.c sbr/b... |
Date: |
Mon, 02 Jan 2006 03:17:43 +0000 |
CVSROOT: /sources/nmh
Module name: nmh
Branch:
Changes by: Josh Bressers <address@hidden> 06/01/02 03:17:42
Modified files:
. : ChangeLog
sbr : Makefile.in add.c brkstring.c client.c concat.c
context_foil.c context_replace.c fmt_addr.c
fmt_new.c fmt_rfc2047.c folder_read.c
folder_realloc.c getarguments.c getcpy.c
lock_file.c m_getfld.c mf.c mts.c putenv.c
readconfig.c ruserpass.c seq_list.c strdup.c
vfgets.c
uip : aliasbr.c anno.c annosbr.c conflict.c flist.c
folder.c forw.c install-mh.c mark.c
mhbuildsbr.c mhlist.c mhlsbr.c mhn.c mhparse.c
mhpath.c mhshow.c mhstore.c mhtest.c mshcmds.c
packf.c pick.c popi.c popsbr.c rcvdist.c
refile.c replsbr.c rmm.c scan.c scansbr.c
sendsbr.c sortm.c vmhsbr.c whatnowsbr.c
Added files:
h : utils.h
sbr : utils.c
Log message:
* patch #3966: Create a mh_xmalloc function to prevent mistakes when
calling malloc.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/ChangeLog.diff?tr1=1.217&tr2=1.218&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/h/utils.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/Makefile.in.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/add.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/brkstring.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/client.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/concat.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/context_foil.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/context_replace.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/fmt_addr.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/fmt_new.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/fmt_rfc2047.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/folder_read.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/folder_realloc.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/getarguments.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/getcpy.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/lock_file.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/m_getfld.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/mf.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/mts.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/putenv.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/readconfig.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/ruserpass.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/seq_list.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/strdup.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/utils.c?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/sbr/vfgets.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/aliasbr.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/anno.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/annosbr.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/conflict.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/flist.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/folder.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/forw.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/install-mh.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mark.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhbuildsbr.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhlist.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhlsbr.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhn.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhparse.c.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhpath.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhshow.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhstore.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mhtest.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/mshcmds.c.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/packf.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/pick.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/popi.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/popsbr.c.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/rcvdist.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/refile.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/replsbr.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/rmm.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/scan.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/scansbr.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/sendsbr.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/sortm.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/vmhsbr.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/nmh/nmh/uip/whatnowsbr.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
Patches:
Index: nmh/ChangeLog
diff -u nmh/ChangeLog:1.217 nmh/ChangeLog:1.218
--- nmh/ChangeLog:1.217 Sat Dec 24 17:53:26 2005
+++ nmh/ChangeLog Mon Jan 2 03:17:41 2006
@@ -1,3 +1,8 @@
+2006-01-01 Josh Bressers <address@hidden>
+
+ * patch #3966: Create a mh_xmalloc function to prevent mistakes when
+ calling malloc.
+
2005-12-24 Peter Maydell <address@hidden>
* Bug #15285: Don't use $< in target rules in makefiles, as POSIX
Index: nmh/sbr/Makefile.in
diff -u nmh/sbr/Makefile.in:1.20 nmh/sbr/Makefile.in:1.21
--- nmh/sbr/Makefile.in:1.20 Sat Dec 24 17:53:26 2005
+++ nmh/sbr/Makefile.in Mon Jan 2 03:17:42 2006
@@ -1,7 +1,7 @@
#
# Makefile for sbr subdirectory
#
-# $Id: Makefile.in,v 1.20 2005/12/24 17:53:26 pm215 Exp $
+# $Id: Makefile.in,v 1.21 2006/01/02 03:17:42 bress Exp $
#
SHELL = /bin/sh
@@ -75,7 +75,7 @@
seq_setprev.c seq_setunseen.c showfile.c signals.c \
smatch.c snprintb.c ssequal.c strcasecmp.c \
strindex.c trimcpy.c uprf.c vfgets.c fmt_def.c \
- m_msgdef.c mf.c
+ m_msgdef.c mf.c utils.c
# source for compatibility functions
COMPAT = snprintf.c strdup.c strerror.c
Index: nmh/sbr/add.c
diff -u nmh/sbr/add.c:1.2 nmh/sbr/add.c:1.3
--- nmh/sbr/add.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/add.c Mon Jan 2 03:17:42 2006
@@ -7,7 +7,7 @@
* -- of "s1" and "s2" (note the order) into newly
* -- malloc'ed memory. Then free "s1".
*
- * $Id: add.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: add.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -15,6 +15,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
char *
add (char *s2, char *s1)
@@ -28,8 +29,7 @@
len2 = strlen (s2);
- if (!(cp = malloc (len1 + len2 + 1)))
- adios (NULL, "unable to allocate string storage");
+ cp = mh_xmalloc (len1 + len2 + 1);
/* Copy s1 and free it */
if (s1) {
Index: nmh/sbr/brkstring.c
diff -u nmh/sbr/brkstring.c:1.2 nmh/sbr/brkstring.c:1.3
--- nmh/sbr/brkstring.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/brkstring.c Mon Jan 2 03:17:42 2006
@@ -3,7 +3,7 @@
* brkstring.c -- (destructively) split a string into
* -- an array of substrings
*
- * $Id: brkstring.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: brkstring.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/* allocate this number of pointers at a time */
#define NUMBROKEN 256
@@ -33,8 +34,7 @@
/* allocate initial space for pointers on first call */
if (!broken) {
len = NUMBROKEN;
- if (!(broken = (char **) malloc ((size_t) (len * sizeof(*broken)))))
- adios (NULL, "unable to malloc array in brkstring");
+ broken = (char **) mh_xmalloc ((size_t) (len * sizeof(*broken)));
}
/*
Index: nmh/sbr/client.c
diff -u nmh/sbr/client.c:1.2 nmh/sbr/client.c:1.3
--- nmh/sbr/client.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/client.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* client.c -- connect to a server
*
- * $Id: client.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: client.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
#include <h/mh.h>
#include <h/mts.h>
+#include <h/utils.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -270,7 +271,7 @@
strncpy (response, "Out of memory.", len_response);
return OOPS2;
}
- ticket = (KTEXT) malloc (sizeof(KTEXT_ST));
+ ticket = (KTEXT) mh_xmalloc (sizeof(KTEXT_ST));
rem = krb_sendauth (0L, sd, ticket, kservice, instance,
(char *) krb_realmofhost (instance),
(unsigned long) 0, &msg_data, &cred, schedule,
@@ -474,8 +475,7 @@
size_t len;
len = strlen(str) + 1;
- if (!(cp = malloc(len)))
- return NULL;
+ cp = mh_xmalloc(len);
memcpy (cp, str, len);
return cp;
Index: nmh/sbr/concat.c
diff -u nmh/sbr/concat.c:1.2 nmh/sbr/concat.c:1.3
--- nmh/sbr/concat.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/concat.c Mon Jan 2 03:17:42 2006
@@ -3,7 +3,7 @@
* concat.c -- concatenate a variable number (minimum of 1)
* of strings in managed memory
*
- * $Id: concat.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: concat.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
char *
@@ -26,8 +27,7 @@
len += strlen (cp);
va_end(list);
- if (!(dp = sp = malloc(len)))
- adios (NULL, "unable to allocate string storage");
+ dp = sp = mh_xmalloc(len);
sp = copy(s1, sp);
Index: nmh/sbr/context_foil.c
diff -u nmh/sbr/context_foil.c:1.3 nmh/sbr/context_foil.c:1.4
--- nmh/sbr/context_foil.c:1.3 Sun Nov 13 23:51:18 2005
+++ nmh/sbr/context_foil.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* context_foil.c -- foil search of profile and context
*
- * $Id: context_foil.c,v 1.3 2005/11/13 23:51:18 pm215 Exp $
+ * $Id: context_foil.c,v 1.4 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
* Foil search of users .mh_profile
@@ -45,10 +46,7 @@
* If path is given, create a minimal profile/context list
*/
if (path) {
- if (!(m_defs = (struct node *) malloc (sizeof(*np)))) {
- advise (NULL, "unable to allocate profile storage");
- return -1;
- }
+ m_defs = (struct node *) mh_xmalloc (sizeof(*np));
np = m_defs;
if (!(np->n_name = strdup ("Path"))) {
Index: nmh/sbr/context_replace.c
diff -u nmh/sbr/context_replace.c:1.3 nmh/sbr/context_replace.c:1.4
--- nmh/sbr/context_replace.c:1.3 Mon Nov 18 18:25:02 2002
+++ nmh/sbr/context_replace.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* context_replace.c -- add/replace an entry in the context/profile list
*
- * $Id: context_replace.c,v 1.3 2002/11/18 18:25:02 jon Exp $
+ * $Id: context_replace.c,v 1.4 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
void
@@ -21,8 +22,7 @@
* If list is emtpy, allocate head of profile/context list.
*/
if (!m_defs) {
- if (!(m_defs = (struct node *) malloc (sizeof(*np))))
- adios (NULL, "unable to allocate profile storage");
+ m_defs = (struct node *) mh_xmalloc (sizeof(*np));
np = m_defs;
np->n_name = getcpy (key);
@@ -56,9 +56,7 @@
/*
* Else add this new entry at the end
*/
- np->n_next = (struct node *) malloc (sizeof(*np));
- if (!np->n_next)
- adios (NULL, "unable to allocate profile storage");
+ np->n_next = (struct node *) mh_xmalloc (sizeof(*np));
np = np->n_next;
np->n_name = getcpy (key);
Index: nmh/sbr/fmt_addr.c
diff -u nmh/sbr/fmt_addr.c:1.3 nmh/sbr/fmt_addr.c:1.4
--- nmh/sbr/fmt_addr.c:1.3 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/fmt_addr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* fmt_addr.c -- format an address field (from fmt_scan)
*
- * $Id: fmt_addr.c,v 1.3 2002/07/02 22:09:14 kenh Exp $
+ * $Id: fmt_addr.c,v 1.4 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
+#include <h/utils.h>
static char *buf; /* our current working buffer */
static char *bufend; /* end of working buffer */
@@ -63,9 +64,7 @@
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = malloc (BUFINCR);
- if (! buf)
- adios (NULL, "formataddr: couldn't allocate buffer space");
+ buf = mh_xmalloc (BUFINCR);
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
Index: nmh/sbr/fmt_new.c
diff -u nmh/sbr/fmt_new.c:1.2 nmh/sbr/fmt_new.c:1.3
--- nmh/sbr/fmt_new.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/fmt_new.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* fmt_new.c -- read format file/string and normalize
*
- * $Id: fmt_new.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: fmt_new.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
#define QUOTE '\\'
@@ -41,8 +42,7 @@
if (fstat (fileno (fp), &st) == -1)
adios (form, "unable to stat format file");
- if (!(formats = malloc ((size_t) st.st_size + 1)))
- adios (form, "unable to allocate space for format");
+ formats = mh_xmalloc ((size_t) st.st_size + 1);
if (read (fileno(fp), formats, (int) st.st_size) != st.st_size)
adios (form, "error reading format file");
Index: nmh/sbr/fmt_rfc2047.c
diff -u nmh/sbr/fmt_rfc2047.c:1.4 nmh/sbr/fmt_rfc2047.c:1.5
--- nmh/sbr/fmt_rfc2047.c:1.4 Sun Nov 6 21:54:40 2005
+++ nmh/sbr/fmt_rfc2047.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* fmt_rfc2047.c -- decode RFC-2047 header format
*
- * $Id: fmt_rfc2047.c,v 1.4 2005/11/06 21:54:40 pm215 Exp $
+ * $Id: fmt_rfc2047.c,v 1.5 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
#ifdef HAVE_ICONV
# include <iconv.h>
# include <errno.h>
@@ -198,8 +199,7 @@
if (use_iconv) {
saveq = q;
savedstlen = dstlen;
- if (!(q = convbuf = (char *)malloc(endofmime - startofmime)))
- continue;
+ q = convbuf = (char *) mh_xmalloc(endofmime - startofmime);
}
/* ADDCHR2 is for adding characters when q is or might be convbuf:
* in this case on buffer-full we want to run iconv before returning.
Index: nmh/sbr/folder_read.c
diff -u nmh/sbr/folder_read.c:1.4 nmh/sbr/folder_read.c:1.5
--- nmh/sbr/folder_read.c:1.4 Wed May 18 12:57:40 2005
+++ nmh/sbr/folder_read.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* folder_read.c -- initialize folder structure and read folder
*
- * $Id: folder_read.c,v 1.4 2005/05/18 12:57:40 opk Exp $
+ * $Id: folder_read.c,v 1.5 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/* We allocate the `mi' array 1024 elements at a time */
#define NUMMSGS 1024
@@ -44,8 +45,7 @@
}
/* Allocate the main structure for folder information */
- if (!(mp = (struct msgs *) malloc ((size_t) sizeof(*mp))))
- adios (NULL, "unable to allocate folder storage");
+ mp = (struct msgs *) mh_xmalloc ((size_t) sizeof(*mp));
clear_folder_flags (mp);
mp->foldpath = name;
@@ -66,8 +66,7 @@
* name of the messages in this folder.
*/
len = NUMMSGS;
- if (!(mi = (int *) malloc ((size_t) (len * sizeof(*mi)))))
- adios (NULL, "unable to allocate storage");
+ mi = (int *) mh_xmalloc ((size_t) (len * sizeof(*mi)));
while ((dp = readdir (dd))) {
if ((msgnum = m_atoi (dp->d_name)) && msgnum > 0) {
@@ -138,8 +137,7 @@
/*
* Allocate space for status of each message.
*/
- if (!(mp->msgstats = malloc (MSGSTATSIZE(mp, mp->lowoff, mp->hghoff))))
- adios (NULL, "unable to allocate storage for msgstats");
+ mp->msgstats = mh_xmalloc (MSGSTATSIZE(mp, mp->lowoff, mp->hghoff));
/*
* Clear all the flag bits for all the message
Index: nmh/sbr/folder_realloc.c
diff -u nmh/sbr/folder_realloc.c:1.2 nmh/sbr/folder_realloc.c:1.3
--- nmh/sbr/folder_realloc.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/folder_realloc.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* folder_realloc.c -- realloc a folder/msgs structure
*
- * $Id: folder_realloc.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: folder_realloc.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
* Reallocate some of the space in the folder
@@ -58,10 +59,7 @@
seqset_t *tmpstats;
/* first allocate the new message status space */
- if (!(tmpstats = malloc (MSGSTATSIZE(mp, lo, hi)))) {
- advise (NULL, "unable to reallocate message storage");
- return NULL;
- }
+ tmpstats = mh_xmalloc (MSGSTATSIZE(mp, lo, hi));
/* then copy messages status array with shift */
if (mp->nummsg > 0) {
Index: nmh/sbr/getarguments.c
diff -u nmh/sbr/getarguments.c:1.2 nmh/sbr/getarguments.c:1.3
--- nmh/sbr/getarguments.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/getarguments.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* getarguments.c -- Get the argument vector ready to go.
*
- * $Id: getarguments.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: getarguments.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
char **
getarguments (char *invo_name, int argc, char **argv, int check_context)
@@ -30,8 +31,7 @@
n++;
}
- if (!(arguments = (char **) malloc ((argc + n) * sizeof(*arguments))))
- adios (NULL, "unable to malloc argument storage");
+ arguments = (char **) mh_xmalloc ((argc + n) * sizeof(*arguments));
bp = arguments;
/* Copy any arguments from profile/context */
Index: nmh/sbr/getcpy.c
diff -u nmh/sbr/getcpy.c:1.2 nmh/sbr/getcpy.c:1.3
--- nmh/sbr/getcpy.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/getcpy.c Mon Jan 2 03:17:42 2006
@@ -6,7 +6,7 @@
* OF GETCPY WITH STRDUP. BUT THIS WILL REQUIRE
* CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES.
*
- * $Id: getcpy.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: getcpy.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -14,6 +14,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
char *
@@ -24,12 +25,10 @@
if (str) {
len = strlen(str) + 1;
- if (!(cp = malloc (len)))
- adios (NULL, "unable to allocate string storage");
+ cp = mh_xmalloc (len);
memcpy (cp, str, len);
} else {
- if (!(cp = malloc ((size_t) 1)))
- adios (NULL, "unable to allocate string storage");
+ cp = mh_xmalloc ((size_t) 1);
*cp = '\0';
}
return cp;
Index: nmh/sbr/lock_file.c
diff -u nmh/sbr/lock_file.c:1.11 nmh/sbr/lock_file.c:1.12
--- nmh/sbr/lock_file.c:1.11 Tue Oct 12 20:40:25 2004
+++ nmh/sbr/lock_file.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* lock.c -- routines to lock/unlock files
*
- * $Id: lock_file.c,v 1.11 2004/10/12 20:40:25 jon Exp $
+ * $Id: lock_file.c,v 1.12 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -19,6 +19,7 @@
#include <h/mh.h>
#include <h/signals.h>
+#include <h/utils.h>
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
@@ -542,15 +543,11 @@
struct lock *lp;
size_t len;
- if (!(lp = (struct lock *) malloc (sizeof(*lp))))
- return;
+ lp = (struct lock *) mh_xmalloc (sizeof(*lp));
len = strlen(curlock) + 1;
lp->l_fd = fd;
- if (!(lp->l_lock = malloc (len))) {
- free ((char *) lp);
- return;
- }
+ lp->l_lock = mh_xmalloc (len);
memcpy (lp->l_lock, curlock, len);
lp->l_next = l_top;
Index: nmh/sbr/m_getfld.c
diff -u nmh/sbr/m_getfld.c:1.10 nmh/sbr/m_getfld.c:1.11
--- nmh/sbr/m_getfld.c:1.10 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/m_getfld.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* m_getfld.c -- read/parse a message
*
- * $Id: m_getfld.c,v 1.10 2002/07/02 22:09:14 kenh Exp $
+ * $Id: m_getfld.c,v 1.11 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
#include <h/mh.h>
#include <h/mts.h>
+#include <h/utils.h>
/* This module has a long and checkered history. First, it didn't burst
maildrops correctly because it considered two CTRL-A:s in a row to be
@@ -562,7 +563,7 @@
msg_style = MS_MMDF;
}
c = strlen (delimstr);
- fdelim = (unsigned char *) malloc((size_t) (c + 3));
+ fdelim = (unsigned char *) mh_xmalloc((size_t) (c + 3));
*fdelim++ = '\0';
*fdelim = '\n';
msg_delim = (char *)fdelim+1;
Index: nmh/sbr/mf.c
diff -u nmh/sbr/mf.c:1.3 nmh/sbr/mf.c:1.4
--- nmh/sbr/mf.c:1.3 Sun Nov 13 22:36:07 2005
+++ nmh/sbr/mf.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mf.c -- mail filter subroutines
*
- * $Id: mf.c,v 1.3 2005/11/13 22:36:07 pm215 Exp $
+ * $Id: mf.c,v 1.4 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
#include <h/mf.h>
#include <ctype.h>
#include <stdio.h>
+#include <h/utils.h>
/*
* static prototypes
@@ -42,8 +43,8 @@
for(;;)
pause();
}
- if ((p = malloc ((size_t) (strlen (s) + 2))))
- strcpy (p, s);
+ p = mh_xmalloc ((size_t) (strlen (s) + 2));
+ strcpy (p, s);
return p;
}
@@ -56,8 +57,8 @@
if (!s2)
return getcpy (s1);
- if ((p = malloc ((size_t) (strlen (s1) + strlen (s2) + 2))))
- sprintf (p, "%s%s", s2, s1);
+ p = mh_xmalloc ((size_t) (strlen (s1) + strlen (s2) + 2));
+ sprintf (p, "%s%s", s2, s1);
free (s2);
return p;
}
@@ -934,8 +935,7 @@
static char *pp = NULL;
if (pp == NULL)
- if (!(pp = malloc ((size_t) (len = BUFSIZ))))
- return NOTOK;
+ pp = mh_xmalloc ((size_t) (len = BUFSIZ));
for (ep = (cp = pp) + len - 2;;) {
switch (i = getc (in)) {
Index: nmh/sbr/mts.c
diff -u nmh/sbr/mts.c:1.3 nmh/sbr/mts.c:1.4
--- nmh/sbr/mts.c:1.3 Tue Sep 30 16:58:43 2003
+++ nmh/sbr/mts.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mts.c -- definitions for the mail transport system
*
- * $Id: mts.c,v 1.3 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mts.c,v 1.4 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
#include <h/mh.h> /* for snprintf() */
#include <h/nmh.h>
+#include <h/utils.h>
#define nmhetcdir(file) NMHETCDIR#file
@@ -271,8 +272,8 @@
*bp = 0;
len = strlen (buffer) + 1;
- if ((bp = malloc (len)))
- memcpy (bp, buffer, len);
+ bp = mh_xmalloc (len);
+ memcpy (bp, buffer, len);
return bp;
}
Index: nmh/sbr/putenv.c
diff -u nmh/sbr/putenv.c:1.2 nmh/sbr/putenv.c:1.3
--- nmh/sbr/putenv.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/putenv.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* putenv.c -- (un)set an envariable
*
- * $Id: putenv.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: putenv.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
extern char **environ;
@@ -27,8 +28,7 @@
register int i;
register char **ep, **nep, *cp;
- if (!(cp = malloc ((size_t) (strlen (name) + strlen (value) + 2))))
- return 1;
+ cp = mh_xmalloc ((size_t) (strlen (name) + strlen (value) + 2));
sprintf (cp, "%s=%s", name, value);
@@ -38,8 +38,7 @@
return 0;
}
- if (!(nep = (char **) malloc ((size_t) ((i + 2) * sizeof(*nep)))))
- return 1;
+ nep = (char **) mh_xmalloc ((size_t) ((i + 2) * sizeof(*nep)));
for (ep = environ, i = 0; *ep; nep[i++] = *ep++)
continue;
Index: nmh/sbr/readconfig.c
diff -u nmh/sbr/readconfig.c:1.2 nmh/sbr/readconfig.c:1.3
--- nmh/sbr/readconfig.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/readconfig.c Mon Jan 2 03:17:42 2006
@@ -3,7 +3,7 @@
* readconfig.c -- base routine to read nmh configuration files
* -- such as nmh profile, context file, or mhn.defaults.
*
- * $Id: readconfig.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: readconfig.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
struct procstr {
char *procname;
@@ -65,8 +66,7 @@
case FLD:
case FLDPLUS:
case FLDEOF:
- if (!(np = (struct node *) malloc (sizeof(*np))))
- adios (NULL, "unable to allocate profile storage");
+ np = (struct node *) mh_xmalloc (sizeof(*np));
*npp = np;
*(npp = &np->n_next) = NULL;
np->n_name = getcpy (name);
Index: nmh/sbr/ruserpass.c
diff -u nmh/sbr/ruserpass.c:1.5 nmh/sbr/ruserpass.c:1.6
--- nmh/sbr/ruserpass.c:1.5 Tue Sep 30 16:58:43 2003
+++ nmh/sbr/ruserpass.c Mon Jan 2 03:17:42 2006
@@ -15,10 +15,11 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ruserpass.c,v 1.5 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: ruserpass.c,v 1.6 2006/01/02 03:17:42 bress Exp $
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <pwd.h>
#include <errno.h>
@@ -100,7 +101,7 @@
switch(t) {
case LOGIN:
if (token() && *aname == 0) {
- *aname = malloc((size_t) strlen(tokval) + 1);
+ *aname = mh_xmalloc((size_t) strlen(tokval) + 1);
strcpy(*aname, tokval);
}
break;
@@ -112,7 +113,7 @@
goto bad;
}
if (token() && *apass == 0) {
- *apass = malloc((size_t) strlen(tokval) + 1);
+ *apass = mh_xmalloc((size_t) strlen(tokval) + 1);
strcpy(*apass, tokval);
}
break;
@@ -153,7 +154,7 @@
myname = tmp;
}
- *aname = malloc((size_t) strlen(myname) + 1);
+ *aname = mh_xmalloc((size_t) strlen(myname) + 1);
strcpy (*aname, myname);
}
@@ -168,7 +169,7 @@
mypass = *aname;
}
- *apass = malloc((size_t) strlen(mypass) + 1);
+ *apass = mh_xmalloc((size_t) strlen(mypass) + 1);
strcpy (*apass, mypass);
}
Index: nmh/sbr/seq_list.c
diff -u nmh/sbr/seq_list.c:1.2 nmh/sbr/seq_list.c:1.3
--- nmh/sbr/seq_list.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/seq_list.c Mon Jan 2 03:17:42 2006
@@ -3,7 +3,7 @@
* seq_list.c -- Get all messages in a sequence and return them
* -- as a space separated list of message ranges.
*
- * $Id: seq_list.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: seq_list.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/* allocate this much buffer space at a time */
#define MAXBUFFER 1024
@@ -29,8 +30,7 @@
/* On first invocation, allocate initial buffer space */
if (!buffer) {
len = MAXBUFFER;
- if (!(buffer = malloc ((size_t) len)))
- adios (NULL, "unable to malloc storage in seq_list");
+ buffer = mh_xmalloc ((size_t) len);
}
/*
Index: nmh/sbr/strdup.c
diff -u nmh/sbr/strdup.c:1.3 nmh/sbr/strdup.c:1.4
--- nmh/sbr/strdup.c:1.3 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/strdup.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* strdup.c -- duplicate a string
*
- * $Id: strdup.c,v 1.3 2002/07/02 22:09:14 kenh Exp $
+ * $Id: strdup.c,v 1.4 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
char *
@@ -22,8 +23,7 @@
return NULL;
len = strlen(str) + 1;
- if (!(cp = malloc (len)))
- return NULL;
+ cp = mh_xmalloc (len);
memcpy (cp, str, len);
return cp;
}
Index: nmh/sbr/vfgets.c
diff -u nmh/sbr/vfgets.c:1.2 nmh/sbr/vfgets.c:1.3
--- nmh/sbr/vfgets.c:1.2 Tue Jul 2 22:09:14 2002
+++ nmh/sbr/vfgets.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* vfgets.c -- virtual fgets
*
- * $Id: vfgets.c,v 1.2 2002/07/02 22:09:14 kenh Exp $
+ * $Id: vfgets.c,v 1.3 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
#define QUOTE '\\'
@@ -23,8 +24,7 @@
static char *pp = NULL;
if (pp == NULL)
- if (!(pp = malloc ((size_t) (len = BUFSIZ))))
- adios (NULL, "unable to allocate string storage");
+ pp = mh_xmalloc ((size_t) (len = BUFSIZ));
for (ep = (cp = pp) + len - 1;;) {
if (fgets (cp, ep - cp + 1, in) == NULL) {
Index: nmh/uip/aliasbr.c
diff -u nmh/uip/aliasbr.c:1.4 nmh/uip/aliasbr.c:1.5
--- nmh/uip/aliasbr.c:1.4 Tue Jul 2 22:09:14 2002
+++ nmh/uip/aliasbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* aliasbr.c -- new aliasing mechanism
*
- * $Id: aliasbr.c,v 1.4 2002/07/02 22:09:14 kenh Exp $
+ * $Id: aliasbr.c,v 1.5 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
#include <h/mh.h>
#include <h/aliasbr.h>
+#include <h/utils.h>
#include <grp.h>
#include <pwd.h>
@@ -475,9 +476,7 @@
if (!strcmp (pp, ad->ad_text))
return;
- ad = (struct adr *) malloc (sizeof(*ad));
- if (ad == NULL)
- return;
+ ad = (struct adr *) mh_xmalloc (sizeof(*ad));
ad->ad_text = getcpy (pp);
ad->ad_local = strchr(pp, '@') == NULL && strchr(pp, '!') == NULL;
ad->ad_next = NULL;
@@ -522,8 +521,7 @@
{
register struct aka *p;
- if (!(p = (struct aka *) malloc (sizeof(*p))))
- return NULL;
+ p = (struct aka *) mh_xmalloc (sizeof(*p));
p->ak_name = getcpy (id);
p->ak_visible = 0;
@@ -544,8 +542,7 @@
{
register struct home *p;
- if (!(p = (struct home *) malloc (sizeof(*p))))
- return NULL;
+ p = (struct home *) mh_xmalloc (sizeof(*p));
p->h_name = getcpy (pw->pw_name);
p->h_uid = pw->pw_uid;
Index: nmh/uip/anno.c
diff -u nmh/uip/anno.c:1.6 nmh/uip/anno.c:1.7
--- nmh/uip/anno.c:1.6 Wed Dec 7 21:25:47 2005
+++ nmh/uip/anno.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* anno.c -- annotate messages
*
- * $Id: anno.c,v 1.6 2005/12/07 21:25:47 jon Exp $
+ * $Id: anno.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -46,6 +46,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
* We allocate space for messages (msgs array)
@@ -127,8 +128,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
while ((cp = *argp++)) {
if (*cp == '-') {
Index: nmh/uip/annosbr.c
diff -u nmh/uip/annosbr.c:1.6 nmh/uip/annosbr.c:1.7
--- nmh/uip/annosbr.c:1.6 Wed Dec 7 21:25:47 2005
+++ nmh/uip/annosbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* annosbr.c -- prepend annotation to messages
*
- * $Id: annosbr.c,v 1.6 2005/12/07 21:25:47 jon Exp $
+ * $Id: annosbr.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
#include <h/mh.h>
#include <h/tws.h>
+#include <h/utils.h>
#include <fcntl.h>
#include <errno.h>
#include <utime.h>
@@ -93,8 +94,7 @@
* This buffer might need to be quite large, so we grow it as needed.
*/
- if ((field = (char *)malloc(field_size = 256)) == (char *)0)
- adios(NULL, "can't allocate field buffer.");
+ field = (char *)mh_xmalloc(field_size = 256);
/*
* Get the length of the field name since we use it often.
@@ -208,8 +208,7 @@
if ((fp = fdopen(fd, "r")) == (FILE *)0)
adios(NULL, "unable to fdopen file.");
- if ((field = (char *)malloc(field_size = 256)) == (char *)0)
- adios(NULL, "can't allocate field buffer.");
+ field = (char *)mh_xmalloc(field_size = 256);
}
/*
Index: nmh/uip/conflict.c
diff -u nmh/uip/conflict.c:1.6 nmh/uip/conflict.c:1.7
--- nmh/uip/conflict.c:1.6 Tue Jul 2 22:09:14 2002
+++ nmh/uip/conflict.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* conflict.c -- check for conflicts in mail system
*
- * $Id: conflict.c,v 1.6 2002/07/02 22:09:14 kenh Exp $
+ * $Id: conflict.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -13,6 +13,7 @@
#include <fcntl.h>
#include <h/aliasbr.h>
#include <h/mts.h>
+#include <h/utils.h>
#include <grp.h>
#include <pwd.h>
@@ -189,8 +190,7 @@
/* allocate space NGRPS at a time */
numgroups = 0;
maxgroups = NGRPS;
- if (!(grps = (char **) malloc((size_t) (maxgroups * sizeof(*grps)))))
- adios (NULL, "unable to allocate group name storage");
+ grps = (char **) mh_xmalloc((size_t) (maxgroups * sizeof(*grps)));
setgrent ();
while ((gr = getgrent ())) {
Index: nmh/uip/flist.c
diff -u nmh/uip/flist.c:1.6 nmh/uip/flist.c:1.7
--- nmh/uip/flist.c:1.6 Wed Nov 2 17:22:27 2005
+++ nmh/uip/flist.c Mon Jan 2 03:17:42 2006
@@ -13,10 +13,11 @@
* makes no warranty about the software, its performance or its conformity to
* any specification.
*
- * $Id: flist.c,v 1.6 2005/11/02 17:22:27 opk Exp $
+ * $Id: flist.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*/
#include <h/mh.h>
+#include <h/utils.h>
#define FALSE 0
#define TRUE 1
@@ -148,8 +149,7 @@
/* allocate the initial space to record the folder names */
numfolders = 0;
maxfolders = MAXFOLDERS;
- if (!(foldersToDo = (char **) malloc ((size_t) (maxfolders *
sizeof(*foldersToDo)))))
- adios (NULL, "unable to allocate folder storage");
+ foldersToDo = (char **) mh_xmalloc ((size_t) (maxfolders *
sizeof(*foldersToDo)));
/* no sequences yet */
numsequences = 0;
@@ -306,7 +306,7 @@
AllocFolders(&orders, &nOrdersAlloced, nOrders + 1);
o = &orders[nOrders++];
o->priority = priority++;
- o->name = (char *) malloc(p - s + 1);
+ o->name = (char *) mh_xmalloc(p - s + 1);
strncpy(o->name, s, p - s);
o->name[p - s] = 0;
} else
@@ -652,7 +652,7 @@
return;
if (*f == NULL) {
*nfa = 10;
- *f = (struct Folder *) malloc (*nfa * (sizeof(struct Folder)));
+ *f = (struct Folder *) mh_xmalloc (*nfa * (sizeof(struct Folder)));
} else {
*nfa *= 2;
*f = (struct Folder *) realloc (*f, *nfa * (sizeof(struct Folder)));
Index: nmh/uip/folder.c
diff -u nmh/uip/folder.c:1.6 nmh/uip/folder.c:1.7
--- nmh/uip/folder.c:1.6 Tue Sep 30 16:58:00 2003
+++ nmh/uip/folder.c Mon Jan 2 03:17:42 2006
@@ -4,7 +4,7 @@
* -- push/pop a folder onto/from the folder stack
* -- list the folder stack
*
- * $Id: folder.c,v 1.6 2003/09/30 16:58:00 gbburkhardt Exp $
+ * $Id: folder.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <errno.h>
static struct swit switches[] = {
@@ -353,13 +354,11 @@
/* Allocate initial space to record folder names */
maxfolders = NUMFOLDERS;
- if ((folds = malloc (maxfolders * sizeof(char *))) == NULL)
- adios (NULL, "unable to allocate storage for folder names");
+ folds = mh_xmalloc (maxfolders * sizeof(char *));
/* Allocate initial space to record folder information */
maxFolderInfo = NUMFOLDERS;
- if ((fi = malloc (maxFolderInfo * sizeof(*fi))) == NULL)
- adios (NULL, "unable to allocate storage for folder info");
+ fi = mh_xmalloc (maxFolderInfo * sizeof(*fi));
/*
* Scan the folders
Index: nmh/uip/forw.c
diff -u nmh/uip/forw.c:1.6 nmh/uip/forw.c:1.7
--- nmh/uip/forw.c:1.6 Tue Jul 2 22:09:14 2002
+++ nmh/uip/forw.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* forw.c -- forward a message, or group of messages.
*
- * $Id: forw.c,v 1.6 2002/07/02 22:09:14 kenh Exp $
+ * $Id: forw.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -13,6 +13,7 @@
#include <fcntl.h>
#include <h/fmt_scan.h>
#include <h/tws.h>
+#include <h/utils.h>
#define IFORMAT "digest-issue-%s"
@@ -688,8 +689,7 @@
if ((in = dup (fileno (tmp))) == NOTOK)
adios ("dup", "unable to");
- if ((line = malloc ((unsigned) fmtsize)) == NULL)
- adios (NULL, "unable to allocate format line storage");
+ line = mh_xmalloc ((unsigned) fmtsize);
fmt_scan (fmt, line, fmtsize, dat);
fputs (line, tmp);
free (line);
Index: nmh/uip/install-mh.c
diff -u nmh/uip/install-mh.c:1.5 nmh/uip/install-mh.c:1.6
--- nmh/uip/install-mh.c:1.5 Mon Nov 18 18:25:02 2002
+++ nmh/uip/install-mh.c Mon Jan 2 03:17:42 2006
@@ -1,7 +1,7 @@
/*
* install-mh.c -- initialize the nmh environment of a new user
*
- * $Id: install-mh.c,v 1.5 2002/11/18 18:25:02 jon Exp $
+ * $Id: install-mh.c,v 1.6 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -9,6 +9,7 @@
*/
#include <h/mh.h> /* mh internals */
+#include <h/utils.h>
#include <pwd.h> /* structure for getpwuid()
results */
static struct swit switches[] = {
@@ -180,8 +181,7 @@
/*
* Add some initial elements to the profile/context list
*/
- if (!(m_defs = (struct node *) malloc (sizeof *np)))
- adios (NULL, "unable to allocate profile storage");
+ m_defs = (struct node *) mh_xmalloc (sizeof *np);
np = m_defs;
np->n_name = getcpy ("Path");
np->n_field = getcpy (pathname);
Index: nmh/uip/mark.c
diff -u nmh/uip/mark.c:1.4 nmh/uip/mark.c:1.5
--- nmh/uip/mark.c:1.4 Tue Jul 2 22:09:14 2002
+++ nmh/uip/mark.c Mon Jan 2 03:17:42 2006
@@ -4,7 +4,7 @@
* -- delete messages (s) from sequences in given folder
* -- list sequences in given folder
*
- * $Id: mark.c,v 1.4 2002/07/02 22:09:14 kenh Exp $
+ * $Id: mark.c,v 1.5 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
* We allocate space for messages (msgs array)
@@ -81,8 +82,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mhbuildsbr.c
diff -u nmh/uip/mhbuildsbr.c:1.9 nmh/uip/mhbuildsbr.c:1.10
--- nmh/uip/mhbuildsbr.c:1.9 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mhbuildsbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhbuildsbr.c -- routines to expand/translate MIME composition files
*
- * $Id: mhbuildsbr.c,v 1.9 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mhbuildsbr.c,v 1.10 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -27,6 +27,7 @@
#include <h/tws.h>
#include <h/mime.h>
#include <h/mhparse.h>
+#include <h/utils.h>
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
@@ -785,8 +786,7 @@
HF hp;
/* allocate header field structure */
- if (!(hp = malloc (sizeof(*hp))))
- adios (NULL, "out of memory");
+ hp = mh_xmalloc (sizeof(*hp));
/* link data into header structure */
hp->name = name;
@@ -1553,8 +1553,7 @@
goto no_body;
}
- if ((e->eb_body = bp = malloc ((unsigned) size)) == NULL)
- adios (NULL, "out of memory");
+ e->eb_body = bp = mh_xmalloc ((unsigned) size);
fseek (p->c_fp, p->c_begin, SEEK_SET);
while (size > 0)
switch (cc = fread (bp, sizeof(*bp), size, p->c_fp)) {
Index: nmh/uip/mhlist.c
diff -u nmh/uip/mhlist.c:1.8 nmh/uip/mhlist.c:1.9
--- nmh/uip/mhlist.c:1.8 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mhlist.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhlist.c -- list the contents of MIME messages
*
- * $Id: mhlist.c,v 1.8 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mhlist.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -20,6 +20,7 @@
#include <h/mime.h>
#include <h/mhparse.h>
#include <h/mhcachesbr.h>
+#include <h/utils.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -153,8 +154,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mhlsbr.c
diff -u nmh/uip/mhlsbr.c:1.7 nmh/uip/mhlsbr.c:1.8
--- nmh/uip/mhlsbr.c:1.7 Wed May 18 13:27:44 2005
+++ nmh/uip/mhlsbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhlsbr.c -- main routines for nmh message lister
*
- * $Id: mhlsbr.c,v 1.7 2005/05/18 13:27:44 opk Exp $
+ * $Id: mhlsbr.c,v 1.8 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -14,6 +14,7 @@
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
#include <h/tws.h>
+#include <h/utils.h>
#include <setjmp.h>
#include <signal.h>
@@ -955,8 +956,7 @@
continue;
}
if (dobody && !strcasecmp (c1->c_name, "body")) {
- if ((holder.c_text = malloc (sizeof(buf))) == NULL)
- adios (NULL, "unable to allocate buffer memory");
+ holder.c_text = mh_xmalloc (sizeof(buf));
strncpy (holder.c_text, buf, sizeof(buf));
while (state == BODY) {
putcomp (c1, &holder, BODYCOMP);
@@ -1650,8 +1650,7 @@
cp = dp, len = j;
}
else {
- if ((cp = malloc ((unsigned) i)) == NULL)
- adios (NULL, "unable to allocate face storage");
+ cp = mh_xmalloc ((unsigned) i);
memcpy(cp, buffer, i);
len = i;
}
Index: nmh/uip/mhn.c
diff -u nmh/uip/mhn.c:1.8 nmh/uip/mhn.c:1.9
--- nmh/uip/mhn.c:1.8 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mhn.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhn.c -- display, list, cache, or store the contents of MIME messages
*
- * $Id: mhn.c,v 1.8 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mhn.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -242,8 +242,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mhparse.c
diff -u nmh/uip/mhparse.c:1.12 nmh/uip/mhparse.c:1.13
--- nmh/uip/mhparse.c:1.12 Sun Nov 6 00:32:20 2005
+++ nmh/uip/mhparse.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhparse.c -- routines to parse the contents of MIME messages
*
- * $Id: mhparse.c,v 1.12 2005/11/06 00:32:20 pm215 Exp $
+ * $Id: mhparse.c,v 1.13 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -20,6 +20,7 @@
#include <h/tws.h>
#include <h/mime.h>
#include <h/mhparse.h>
+#include <h/utils.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -584,8 +585,7 @@
HF hp;
/* allocate header field structure */
- if (!(hp = malloc (sizeof(*hp))))
- adios (NULL, "out of memory");
+ hp = mh_xmalloc (sizeof(*hp));
/* link data into header structure */
hp->name = name;
@@ -1303,8 +1303,7 @@
goto no_body;
}
- if ((e->eb_body = bp = malloc ((unsigned) size)) == NULL)
- adios (NULL, "out of memory");
+ e->eb_body = bp = mh_xmalloc ((unsigned) size);
fseek (p->c_fp, p->c_begin, SEEK_SET);
while (size > 0)
switch (cc = fread (bp, sizeof(*bp), size, p->c_fp)) {
Index: nmh/uip/mhpath.c
diff -u nmh/uip/mhpath.c:1.4 nmh/uip/mhpath.c:1.5
--- nmh/uip/mhpath.c:1.4 Tue Jul 2 22:09:14 2002
+++ nmh/uip/mhpath.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhpath.c -- print full pathnames of nmh messages and folders
*
- * $Id: mhpath.c,v 1.4 2002/07/02 22:09:14 kenh Exp $
+ * $Id: mhpath.c,v 1.5 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
static struct swit switches[] = {
#define VERSIONSW 0
@@ -52,8 +53,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mhshow.c
diff -u nmh/uip/mhshow.c:1.8 nmh/uip/mhshow.c:1.9
--- nmh/uip/mhshow.c:1.8 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mhshow.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhshow.c -- display the contents of MIME messages
*
- * $Id: mhshow.c,v 1.8 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mhshow.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -20,6 +20,7 @@
#include <h/mime.h>
#include <h/mhparse.h>
#include <h/mhcachesbr.h>
+#include <h/utils.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -169,8 +170,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mhstore.c
diff -u nmh/uip/mhstore.c:1.8 nmh/uip/mhstore.c:1.9
--- nmh/uip/mhstore.c:1.8 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mhstore.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhstore.c -- store the contents of MIME messages
*
- * $Id: mhstore.c,v 1.8 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mhstore.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -20,6 +20,7 @@
#include <h/mime.h>
#include <h/mhparse.h>
#include <h/mhcachesbr.h>
+#include <h/utils.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -147,8 +148,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mhtest.c
diff -u nmh/uip/mhtest.c:1.8 nmh/uip/mhtest.c:1.9
--- nmh/uip/mhtest.c:1.8 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mhtest.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mhtest.c -- test harness for MIME routines
*
- * $Id: mhtest.c,v 1.8 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mhtest.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -20,6 +20,7 @@
#include <h/mime.h>
#include <h/mhparse.h>
#include <h/mhcachesbr.h>
+#include <h/utils.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -149,8 +150,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/mshcmds.c
diff -u nmh/uip/mshcmds.c:1.12 nmh/uip/mshcmds.c:1.13
--- nmh/uip/mshcmds.c:1.12 Tue Sep 30 16:58:43 2003
+++ nmh/uip/mshcmds.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* mshcmds.c -- command handlers in msh
*
- * $Id: mshcmds.c,v 1.12 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: mshcmds.c,v 1.13 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -21,6 +21,7 @@
#include <signal.h>
#include <h/msh.h>
#include <h/picksbr.h>
+#include <h/utils.h>
static char delim3[] = "-------"; /* from burst.c */
@@ -2160,8 +2161,7 @@
if (*dp == '\\' || *dp == '"' || *dp == '\n')
i++;
i++;
- if ((ep = malloc ((unsigned) i)) == NULL)
- adios (NULL, "out of memory");
+ ep = mh_xmalloc ((unsigned) i);
for (dp = nfs, fp = ep; *dp; dp++) {
if (*dp == '\n') {
*fp++ = '\\', *fp++ = 'n';
Index: nmh/uip/packf.c
diff -u nmh/uip/packf.c:1.5 nmh/uip/packf.c:1.6
--- nmh/uip/packf.c:1.5 Tue Sep 30 16:58:43 2003
+++ nmh/uip/packf.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* packf.c -- pack a nmh folder into a file
*
- * $Id: packf.c,v 1.5 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: packf.c,v 1.6 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
#include <h/mh.h>
#include <fcntl.h>
#include <h/dropsbr.h>
+#include <h/utils.h>
#include <errno.h>
/*
@@ -67,8 +68,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/pick.c
diff -u nmh/uip/pick.c:1.6 nmh/uip/pick.c:1.7
--- nmh/uip/pick.c:1.6 Tue Sep 30 14:19:20 2003
+++ nmh/uip/pick.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* pick.c -- search for messages by content
*
- * $Id: pick.c,v 1.6 2003/09/30 14:19:20 gbburkhardt Exp $
+ * $Id: pick.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
#include <h/mh.h>
#include <h/tws.h>
#include <h/picksbr.h>
+#include <h/utils.h>
/*
* We allocate space for messages (msgs array)
@@ -103,8 +104,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
while ((cp = *argp++)) {
if (*cp == '-') {
Index: nmh/uip/popi.c
diff -u nmh/uip/popi.c:1.8 nmh/uip/popi.c:1.9
--- nmh/uip/popi.c:1.8 Thu Jan 27 16:34:21 2005
+++ nmh/uip/popi.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* popi.c -- POP initiator for MPOP
*
- * $Id: popi.c,v 1.8 2005/01/27 16:34:21 opk Exp $
+ * $Id: popi.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -13,6 +13,7 @@
#include <h/fmt_scan.h>
#include <h/scansbr.h>
#include <h/mts.h>
+#include <h/utils.h>
#include <errno.h>
#ifndef RPOP
@@ -402,8 +403,7 @@
if (*dp == '\\' || *dp == '"' || *dp == '\n')
i++;
i++;
- if ((ep = malloc ((unsigned) i)) == NULL)
- adios (NULL, "out of memory");
+ ep = mh_xmalloc ((unsigned) i);
for (dp = nfs, fp = ep; *dp; dp++) {
if (*dp == '\n') {
*fp++ = '\\', *fp++ = 'n';
Index: nmh/uip/popsbr.c
diff -u nmh/uip/popsbr.c:1.13 nmh/uip/popsbr.c:1.14
--- nmh/uip/popsbr.c:1.13 Sun Nov 6 00:34:56 2005
+++ nmh/uip/popsbr.c Mon Jan 2 03:17:42 2006
@@ -1,7 +1,7 @@
/*
* popsbr.c -- POP client subroutines
*
- * $Id: popsbr.c,v 1.13 2005/11/06 00:34:56 pm215 Exp $
+ * $Id: popsbr.c,v 1.14 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -9,6 +9,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
extern int client(char *args, char *protocol, char *service, int rproto,
char *response, int len_response);
@@ -432,10 +433,7 @@
len = strlen(pass);
- *psecret = (sasl_secret_t *) malloc(sizeof(sasl_secret_t) + len);
-
- if (! *psecret)
- return SASL_NOMEM;
+ *psecret = (sasl_secret_t *) mh_xmalloc(sizeof(sasl_secret_t) + len);
(*psecret)->len = len;
strcpy((char *) (*psecret)->data, pass);
@@ -476,8 +474,8 @@
}
/* put together list of arguments */
- p = pargv = malloc(pargc * sizeof(char *));
- c = *pargv = malloc(plen * sizeof(char));
+ p = pargv = mh_xmalloc(pargc * sizeof(char *));
+ c = *pargv = mh_xmalloc(plen * sizeof(char));
for (cur = pro; *cur; cur++) {
if (isspace(*cur) && cur[1] && !isspace(cur[1])) {
*c++ = '\0';
Index: nmh/uip/rcvdist.c
diff -u nmh/uip/rcvdist.c:1.8 nmh/uip/rcvdist.c:1.9
--- nmh/uip/rcvdist.c:1.8 Tue Jul 2 22:09:15 2002
+++ nmh/uip/rcvdist.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* rcvdist.c -- asynchronously redistribute messages
*
- * $Id: rcvdist.c,v 1.8 2002/07/02 22:09:15 kenh Exp $
+ * $Id: rcvdist.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -14,6 +14,7 @@
#include <h/rcvmail.h>
#include <h/tws.h>
#include <h/mts.h>
+#include <h/utils.h>
static struct swit switches[] = {
#define FORMSW 0
@@ -181,8 +182,7 @@
*--savecomp = 0;
for (i = ncomps; i--;)
- if (!(*nxtbuf++ = malloc (SBUFSIZ)))
- adios (NULL, "unable to allocate component buffer");
+ *nxtbuf++ = mh_xmalloc (SBUFSIZ);
nxtbuf = compbuffers;
tmpbuf = *nxtbuf++;
@@ -248,7 +248,7 @@
finished: ;
i = format_len + char_read + 256;
- scanl = malloc ((size_t) i + 2);
+ scanl = mh_xmalloc ((size_t) i + 2);
dat[0] = dat[1] = dat[2] = dat[4] = 0;
dat[3] = outputlinelen;
fmt_scan (fmt, scanl, i, dat);
Index: nmh/uip/refile.c
diff -u nmh/uip/refile.c:1.7 nmh/uip/refile.c:1.8
--- nmh/uip/refile.c:1.7 Fri Nov 19 05:06:16 2004
+++ nmh/uip/refile.c Mon Jan 2 03:17:42 2006
@@ -3,7 +3,7 @@
* refile.c -- move or link message(s) from a source folder
* -- into one or more destination folders
*
- * $Id: refile.c,v 1.7 2004/11/19 05:06:16 jon Exp $
+ * $Id: refile.c,v 1.8 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <fcntl.h>
#include <errno.h>
@@ -97,8 +98,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/replsbr.c
diff -u nmh/uip/replsbr.c:1.6 nmh/uip/replsbr.c:1.7
--- nmh/uip/replsbr.c:1.6 Wed Oct 5 10:05:24 2005
+++ nmh/uip/replsbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* replsbr.c -- routines to help repl along...
*
- * $Id: replsbr.c,v 1.6 2005/10/05 10:05:24 opk Exp $
+ * $Id: replsbr.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -12,6 +12,7 @@
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/fmt_scan.h>
+#include <h/utils.h>
#include <sys/file.h> /* L_SET */
#include <errno.h>
@@ -104,8 +105,7 @@
*--savecomp = NULL; /* point at zero'd end minus 1 */
for (i = ncomps; i--; )
- if (!(*nxtbuf++ = malloc(SBUFSIZ)))
- adios (NULL, "unable to allocate component buffer");
+ *nxtbuf++ = mh_xmalloc(SBUFSIZ);
nxtbuf = compbuffers; /* point at start */
tmpbuf = *nxtbuf++;
@@ -230,7 +230,7 @@
}
}
i = format_len + char_read + 256;
- scanl = malloc ((size_t) i + 2);
+ scanl = mh_xmalloc ((size_t) i + 2);
dat[0] = 0;
dat[1] = 0;
dat[2] = 0;
@@ -324,9 +324,7 @@
/* if we don't have a buffer yet, get one */
if (bufsiz == 0) {
- buf = malloc (BUFINCR);
- if (! buf)
- adios (NULL, "formataddr: couldn't allocate buffer space");
+ buf = mh_xmalloc (BUFINCR);
last_dst = buf; /* XXX */
bufsiz = BUFINCR - 6; /* leave some slop */
bufend = buf + bufsiz;
Index: nmh/uip/rmm.c
diff -u nmh/uip/rmm.c:1.5 nmh/uip/rmm.c:1.6
--- nmh/uip/rmm.c:1.5 Fri Aug 23 20:37:01 2002
+++ nmh/uip/rmm.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* rmm.c -- remove a message(s)
*
- * $Id: rmm.c,v 1.5 2002/08/23 20:37:01 jon Exp $
+ * $Id: rmm.c,v 1.6 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -10,6 +10,7 @@
*/
#include <h/mh.h>
+#include <h/utils.h>
/*
* We allocate space for message names and ranges
@@ -56,8 +57,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/* parse arguments */
while ((cp = *argp++)) {
Index: nmh/uip/scan.c
diff -u nmh/uip/scan.c:1.10 nmh/uip/scan.c:1.11
--- nmh/uip/scan.c:1.10 Tue Sep 30 16:58:43 2003
+++ nmh/uip/scan.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* scan.c -- display a one-line "scan" listing of folder or messages
*
- * $Id: scan.c,v 1.10 2003/09/30 16:58:43 gbburkhardt Exp $
+ * $Id: scan.c,v 1.11 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -14,6 +14,7 @@
#include <h/scansbr.h>
#include <h/tws.h>
#include <h/mts.h>
+#include <h/utils.h>
#include <errno.h>
/*
@@ -96,8 +97,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
Index: nmh/uip/scansbr.c
diff -u nmh/uip/scansbr.c:1.6 nmh/uip/scansbr.c:1.7
--- nmh/uip/scansbr.c:1.6 Mon Aug 11 01:20:52 2003
+++ nmh/uip/scansbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* scansbr.c -- routines to help scan along...
*
- * $Id: scansbr.c,v 1.6 2003/08/11 01:20:52 jchonig Exp $
+ * $Id: scansbr.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -14,6 +14,7 @@
#include <h/fmt_scan.h>
#include <h/scansbr.h>
#include <h/tws.h>
+#include <h/utils.h>
#ifdef _FSTDIO
# define _ptr _p /* Gag */
@@ -96,8 +97,7 @@
width = MAXSCANL;
}
dat[3] = slwidth = width;
- if ((scanl = (char *) malloc((size_t) (slwidth + 2) )) == NULL)
- adios (NULL, "unable to malloc scan line (%d bytes)", slwidth+2);
+ scanl = (char *) mh_xmalloc((size_t) (slwidth + 2) );
if (outnum)
umask(~m_gmprot());
@@ -133,8 +133,7 @@
used_buf += ncomps+1; *--used_buf = 0;
rlwidth = bodycomp && (width > SBUFSIZ) ? width : SBUFSIZ;
for (i = ncomps; i--; )
- if ((*nxtbuf++ = malloc(rlwidth)) == NULL)
- adios (NULL, "unable to allocate component buffer");
+ *nxtbuf++ = mh_xmalloc(rlwidth);
}
/*
Index: nmh/uip/sendsbr.c
diff -u nmh/uip/sendsbr.c:1.7 nmh/uip/sendsbr.c:1.8
--- nmh/uip/sendsbr.c:1.7 Mon Dec 12 20:26:53 2005
+++ nmh/uip/sendsbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* sendsbr.c -- routines to help WhatNow/Send along
*
- * $Id: sendsbr.c,v 1.7 2005/12/12 20:26:53 bress Exp $
+ * $Id: sendsbr.c,v 1.8 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -15,6 +15,7 @@
#include <signal.h>
#include <fcntl.h>
#include <h/mime.h>
+#include <h/utils.h>
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
@@ -208,8 +209,7 @@
* This buffer might need to be quite large, so we grow it as needed.
*/
- if ((field = (char *)malloc(field_size = 256)) == (char *)0)
- adios(NULL, "can't allocate field buffer.");
+ field = (char *)mh_xmalloc(field_size = 256);
/*
* Scan the draft file for a header field name that matches the -attach
Index: nmh/uip/sortm.c
diff -u nmh/uip/sortm.c:1.8 nmh/uip/sortm.c:1.9
--- nmh/uip/sortm.c:1.8 Fri Oct 15 17:10:58 2004
+++ nmh/uip/sortm.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* sortm.c -- sort messages in a folder by date/time
*
- * $Id: sortm.c,v 1.8 2004/10/15 17:10:58 jon Exp $
+ * $Id: sortm.c,v 1.9 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -11,6 +11,7 @@
#include <h/mh.h>
#include <h/tws.h>
+#include <h/utils.h>
/*
* We allocate space for messages (msgs array)
@@ -99,8 +100,7 @@
*/
nummsgs = 0;
maxmsgs = MAXMSGS;
- if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
- adios (NULL, "unable to allocate storage");
+ msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
/*
* Parse arguments
@@ -223,9 +223,7 @@
/*
* sort a list of pointers to our "messages to be sorted".
*/
- dlist = (struct smsg **) malloc ((nmsgs+1) * sizeof(*dlist));
- if (! dlist)
- adios (NULL, "couldn't allocate sort memory");
+ dlist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*dlist));
for (i = 0; i < nmsgs; i++)
dlist[i] = &smsgs[i];
dlist[nmsgs] = 0;
@@ -252,9 +250,7 @@
struct smsg **slist, **flist;
register struct smsg ***il, **fp, **dp;
- slist = (struct smsg **) malloc ((nmsgs+1) * sizeof(*slist));
- if (! slist)
- adios (NULL, "couldn't allocate sort memory");
+ slist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*slist));
memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist));
qsort((char *)slist, nmsgs, sizeof(*slist), (qsort_comp) subsort);
@@ -272,9 +268,7 @@
* make up the final list, chronological but with
* all the same subjects grouped together.
*/
- flist = (struct smsg **) malloc ((nmsgs+1) * sizeof(*flist));
- if (! flist)
- adios (NULL, "couldn't allocate msg list");
+ flist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*flist));
fp = flist;
for (dp = dlist; *dp;) {
register struct smsg **s = il[(*dp++)->s_msg];
Index: nmh/uip/vmhsbr.c
diff -u nmh/uip/vmhsbr.c:1.6 nmh/uip/vmhsbr.c:1.7
--- nmh/uip/vmhsbr.c:1.6 Tue Jul 2 22:09:15 2002
+++ nmh/uip/vmhsbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* vmhsbr.c -- routines to help vmh along
*
- * $Id: vmhsbr.c,v 1.6 2002/07/02 22:09:15 kenh Exp $
+ * $Id: vmhsbr.c,v 1.7 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -16,6 +16,7 @@
#include <h/mh.h>
#include <h/vmhsbr.h>
+#include <h/utils.h>
#include <errno.h>
static char *types[] = {
@@ -98,8 +99,7 @@
if (read (PEERrfd, (char *) rc_head (rc), RHSIZE (rc)) != RHSIZE (rc))
return rclose (rc, "read from peer lost(1)");
if (rc->rc_len) {
- if ((rc->rc_data = malloc ((unsigned) rc->rc_len + 1)) == NULL)
- return rclose (rc, "malloc of %d lost", rc->rc_len + 1);
+ rc->rc_data = mh_xmalloc ((unsigned) rc->rc_len + 1);
if (read (PEERrfd, rc->rc_data, rc->rc_len) != rc->rc_len)
return rclose (rc, "read from peer lost(2)");
rc->rc_data[rc->rc_len] = 0;
Index: nmh/uip/whatnowsbr.c
diff -u nmh/uip/whatnowsbr.c:1.7 nmh/uip/whatnowsbr.c:1.8
--- nmh/uip/whatnowsbr.c:1.7 Mon Dec 12 22:30:44 2005
+++ nmh/uip/whatnowsbr.c Mon Jan 2 03:17:42 2006
@@ -2,7 +2,7 @@
/*
* whatnowsbr.c -- the WhatNow shell
*
- * $Id: whatnowsbr.c,v 1.7 2005/12/12 22:30:44 jon Exp $
+ * $Id: whatnowsbr.c,v 1.8 2006/01/02 03:17:42 bress Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -44,6 +44,7 @@
#include <fcntl.h>
#include <signal.h>
#include <h/mime.h>
+#include <h/utils.h>
static struct swit whatnowswitches[] = {
#define DFOLDSW 0
@@ -843,8 +844,7 @@
while (argp[i])
i++;
}
- if ((args = (char **) malloc((i + 2) * sizeof(char *))) == NULL)
- adios (NULL, "unable to malloc memory");
+ args = (char **) mh_xmalloc((i + 2) * sizeof(char *));
/*
* For backward compatibility, we need to add -build
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nmh-commits] nmh ./ChangeLog sbr/Makefile.in sbr/add.c sbr/b...,
Josh Bressers <=