]> diplodocus.org Git - nmh/commitdiff
Add NEW(p) that sets p to mh_xmalloc'd memory sized by *p.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 16 Oct 2016 18:38:36 +0000 (19:38 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 16 Oct 2016 18:38:36 +0000 (19:38 +0100)
Use it for the simple cases.  Again, saves having to check the same
identifier is given, possibly far apart after a superfluous cast.

22 files changed:
h/utils.h
sbr/charstring.c
sbr/context_foil.c
sbr/context_replace.c
sbr/crawl_folders.c
sbr/folder_read.c
sbr/lock_file.c
sbr/m_getfld.c
sbr/netsec.c
sbr/oauth.c
sbr/readconfig.c
sbr/vector.c
uip/aliasbr.c
uip/fmttest.c
uip/install-mh.c
uip/mhbuildsbr.c
uip/mhfixmsg.c
uip/mhparse.c
uip/mhshowsbr.c
uip/mhstoresbr.c
uip/new.c
uip/replsbr.c

index 7219143948c26c764124d7defaab5ac12e4c0841..c866a52c194936c5da286bd045e0399ca901a6cb 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -15,6 +15,9 @@ void *mh_xcalloc(size_t nelem, size_t elsize);
 /* Call free(3), if ptr isn't NULL. */
 void mh_xfree(void *ptr);
 
 /* Call free(3), if ptr isn't NULL. */
 void mh_xfree(void *ptr);
 
+/* Set p to point to newly allocated, uninitialised, memory. */
+#define NEW(p) ((p) = mh_xmalloc(sizeof *(p)))
+
 /* Set p to point to newly allocated, zeroed, memory. */
 #define NEW0(p) ((p) = mh_xcalloc(1, sizeof *(p)))
 
 /* Set p to point to newly allocated, zeroed, memory. */
 #define NEW0(p) ((p) = mh_xcalloc(1, sizeof *(p)))
 
index d94961aad604f45cce28dc70e8c1b78f9a73ae5c..00c6598652d8fe2ebef6f662be20fc98ec8bccd2 100644 (file)
@@ -42,8 +42,9 @@ charstring_reserve (charstring_t s, size_t need) {
  */
 charstring_t
 charstring_create (size_t max) {
  */
 charstring_t
 charstring_create (size_t max) {
-    charstring_t s = mh_xmalloc (sizeof *s);
+    charstring_t s;
 
 
+    NEW(s);
     s->max = NMH_MAX_CHARWIDTH * (max ? max : CHARSTRING_DEFAULT_SIZE);
     s->cur = s->buffer = mh_xmalloc (s->max);
     s->chars = 0;
     s->max = NMH_MAX_CHARWIDTH * (max ? max : CHARSTRING_DEFAULT_SIZE);
     s->cur = s->buffer = mh_xmalloc (s->max);
     s->chars = 0;
@@ -54,8 +55,9 @@ charstring_create (size_t max) {
 charstring_t
 charstring_copy (const charstring_t src) {
     const size_t num = src->cur - src->buffer;
 charstring_t
 charstring_copy (const charstring_t src) {
     const size_t num = src->cur - src->buffer;
-    charstring_t s = mh_xmalloc (sizeof *s);
+    charstring_t s;
 
 
+    NEW(s);
     s->max = src->max;
     s->buffer = mh_xmalloc (s->max);
     memcpy (s->buffer, src->buffer, num);
     s->max = src->max;
     s->buffer = mh_xmalloc (s->max);
     memcpy (s->buffer, src->buffer, num);
index 12dab45fff37c9c0a1c0aa6f7a012593a4a1c766..aabac5583291c101d5bb838500fd58bc9fdef6ee 100644 (file)
@@ -44,9 +44,8 @@ context_foil (char *path)
      * If path is given, create a minimal profile/context list
      */
     if (path) {
      * If path is given, create a minimal profile/context list
      */
     if (path) {
-       m_defs = (struct node *) mh_xmalloc (sizeof(*np));
-
-       np = m_defs;
+       NEW(np);
+       m_defs = np;
        if (!(np->n_name = strdup ("Path"))) {
            advise (NULL, "strdup failed");
            return -1;
        if (!(np->n_name = strdup ("Path"))) {
            advise (NULL, "strdup failed");
            return -1;
index 45d5a31d6563cf92c143572d39a401f9f1f39722..0e9e11467d10d007a3ab13a078b5939f3e0d7370 100644 (file)
@@ -20,9 +20,8 @@ context_replace (char *key, char *value)
      * If list is empty, allocate head of profile/context list.
      */
     if (!m_defs) {
      * If list is empty, allocate head of profile/context list.
      */
     if (!m_defs) {
-       m_defs = (struct node *) mh_xmalloc (sizeof(*np));
-
-       np = m_defs;
+       NEW(np);
+        m_defs = np;
        np->n_name = getcpy (key);
        np->n_field = getcpy (value);
        np->n_context = 1;
        np->n_name = getcpy (key);
        np->n_field = getcpy (value);
        np->n_context = 1;
@@ -54,8 +53,7 @@ context_replace (char *key, char *value)
     /*
      * Else add this new entry at the end
      */
     /*
      * Else add this new entry at the end
      */
-    np->n_next = (struct node *) mh_xmalloc (sizeof(*np));
-
+    NEW(np->n_next);
     np = np->n_next;
     np->n_name = getcpy (key);
     np->n_field = getcpy (value);
     np = np->n_next;
     np->n_name = getcpy (key);
     np->n_field = getcpy (value);
index d8bcdba317052484edc8c8b4ee4f0aef3766ef5d..004e8cf2f4b545212a7ebf7dad338be716d5bcd0 100644 (file)
@@ -135,7 +135,8 @@ crawl_folders_body (struct crawl_context *crawl,
 void
 crawl_folders (char *dir, crawl_callback_t *callback, void *baton)
 {
 void
 crawl_folders (char *dir, crawl_callback_t *callback, void *baton)
 {
-    struct crawl_context *crawl = mh_xmalloc (sizeof(*crawl));
+    struct crawl_context *crawl;
+    NEW(crawl);
     crawl->max = CRAWL_NUMFOLDERS;
     crawl->total = crawl->start = crawl->foldp = 0;
     crawl->folders = mh_xmalloc (crawl->max * sizeof(*crawl->folders));
     crawl->max = CRAWL_NUMFOLDERS;
     crawl->total = crawl->start = crawl->foldp = 0;
     crawl->folders = mh_xmalloc (crawl->max * sizeof(*crawl->folders));
index 73ffe43172eddf6ceb4db6fa93c271816e620ac9..e4bac9045e38e01015ad2a045f4c425a12045a53 100644 (file)
@@ -39,8 +39,7 @@ folder_read (char *name, int lockflag)
     }
 
     /* Allocate the main structure for folder information */
     }
 
     /* Allocate the main structure for folder information */
-    mp = (struct msgs *) mh_xmalloc ((size_t) sizeof(*mp));
-
+    NEW(mp);
     clear_folder_flags (mp);
     mp->foldpath = name;
     mp->lowmsg = 0;
     clear_folder_flags (mp);
     mp->foldpath = name;
     mp->lowmsg = 0;
index a8a98118d1b1e5194f51cda4765c6ccdfca5538b..71a559c63efd450a34afc932146595339c7ffd68 100644 (file)
@@ -660,7 +660,7 @@ timerON (char *curlock, int fd)
     struct lock *lp;
     size_t len;
 
     struct lock *lp;
     size_t len;
 
-    lp = (struct lock *) mh_xmalloc (sizeof(*lp));
+    NEW(lp);
 
     len = strlen(curlock) + 1;
     lp->l_fd = fd;
 
     len = strlen(curlock) + 1;
     lp->l_fd = fd;
index 135be1dbd2ea4feab930109109bd397e120de4b6..0fe55499941f874e54cfc20c3a803b66ce70d050 100644 (file)
@@ -268,7 +268,8 @@ void
 m_getfld_state_init (m_getfld_state_t *gstate, FILE *iob) {
     m_getfld_state_t s;
 
 m_getfld_state_init (m_getfld_state_t *gstate, FILE *iob) {
     m_getfld_state_t s;
 
-    s = *gstate = (m_getfld_state_t) mh_xmalloc(sizeof (struct m_getfld_state));
+    NEW(s);
+    *gstate = s;
     s->readpos = s->end = s->msg_buf;
     s->bytes_read = s->total_bytes_read = 0;
     s->last_caller_pos = s->last_internal_pos = 0;
     s->readpos = s->end = s->msg_buf;
     s->bytes_read = s->total_bytes_read = 0;
     s->last_caller_pos = s->last_internal_pos = 0;
index eb28cbac60f6101488db5c866dfac91a49ef1399..c31e7295bea976f75d062b546f4c54c7b4cf990d 100644 (file)
@@ -137,8 +137,9 @@ static int checkascii(const unsigned char *byte, size_t len);
 netsec_context *
 netsec_init(void)
 {
 netsec_context *
 netsec_init(void)
 {
-    netsec_context *nsc = mh_xmalloc(sizeof(*nsc));
+    netsec_context *nsc;
 
 
+    NEW(nsc);
     nsc->ns_readfd = -1;
     nsc->ns_writefd = -1;
     nsc->ns_snoop = 0;
     nsc->ns_readfd = -1;
     nsc->ns_writefd = -1;
     nsc->ns_snoop = 0;
@@ -1052,7 +1053,7 @@ int netsec_get_user(void *context, int id, const char **result,
         */
 
        if (nsc->sasl_creds == NULL) {
         */
 
        if (nsc->sasl_creds == NULL) {
-           nsc->sasl_creds = mh_xmalloc(sizeof(*nsc->sasl_creds));
+           NEW(nsc->sasl_creds);
            nsc->sasl_creds->user = NULL;
            nsc->sasl_creds->password = NULL;
        }
            nsc->sasl_creds->user = NULL;
            nsc->sasl_creds->password = NULL;
        }
@@ -1092,7 +1093,7 @@ netsec_get_password(sasl_conn_t *conn, void *context, int id,
        return SASL_BADPARAM;
 
     if (nsc->sasl_creds == NULL) {
        return SASL_BADPARAM;
 
     if (nsc->sasl_creds == NULL) {
-       nsc->sasl_creds = mh_xmalloc(sizeof(*nsc->sasl_creds));
+       NEW(nsc->sasl_creds);
        nsc->sasl_creds->user = NULL;
        nsc->sasl_creds->password = NULL;
     }
        nsc->sasl_creds->user = NULL;
        nsc->sasl_creds->password = NULL;
     }
index 0cc95e4e3c2ccf0f073a8dd05aefbb520bd088cd..22e69874701331df8f288e2d8e20449c30461f4b 100755 (executable)
@@ -255,8 +255,10 @@ make_user_agent()
 boolean
 mh_oauth_new(mh_oauth_ctx **result, const char *svc_name)
 {
 boolean
 mh_oauth_new(mh_oauth_ctx **result, const char *svc_name)
 {
-    mh_oauth_ctx *ctx = *result = mh_xmalloc(sizeof *ctx);
+    mh_oauth_ctx *ctx;
 
 
+    NEW(ctx);
+    *result = ctx;
     ctx->curl = NULL;
 
     ctx->log = NULL;
     ctx->curl = NULL;
 
     ctx->log = NULL;
@@ -507,7 +509,7 @@ mh_oauth_authorize(const char *code, mh_oauth_ctx *ctx)
         return NULL;
     }
 
         return NULL;
     }
 
-    result = mh_xmalloc(sizeof *result);
+    NEW(result);
     result->ctx = ctx;
     result->access_token = result->refresh_token = NULL;
 
     result->ctx = ctx;
     result->access_token = result->refresh_token = NULL;
 
@@ -622,7 +624,8 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx)
     int state;
     m_getfld_state_t getfld_ctx = 0;
 
     int state;
     m_getfld_state_t getfld_ctx = 0;
 
-    struct user_creds *user_creds = mh_xmalloc(sizeof *user_creds);
+    struct user_creds *user_creds;
+    NEW(user_creds);
     user_creds->alloc = 4;
     user_creds->len = 0;
     user_creds->creds = mh_xmalloc(user_creds->alloc * sizeof *user_creds->creds);
     user_creds->alloc = 4;
     user_creds->len = 0;
     user_creds->creds = mh_xmalloc(user_creds->alloc * sizeof *user_creds->creds);
index 5d1168939d05cb65ac8dd10483b413c601acf557..70984022477423fbbe9c3718fa526bd8f6d4886f 100644 (file)
@@ -61,7 +61,7 @@ readconfig (struct node **npp, FILE *ib, const char *file, int ctx)
        switch (state = m_getfld (&gstate, name, field, &fieldsz, ib)) {
            case FLD:
            case FLDPLUS:
        switch (state = m_getfld (&gstate, name, field, &fieldsz, ib)) {
            case FLD:
            case FLDPLUS:
-               np = (struct node *) mh_xmalloc (sizeof(*np));
+               NEW(np);
                *npp = np;
                *(npp = &np->n_next) = NULL;
                np->n_name = getcpy (name);
                *npp = np;
                *(npp = &np->n_next) = NULL;
                np->n_name = getcpy (name);
@@ -157,11 +157,12 @@ readconfig (struct node **npp, FILE *ib, const char *file, int ctx)
 
 void
 add_profile_entry (const char *key, const char *value) {
 
 void
 add_profile_entry (const char *key, const char *value) {
-    struct node *newnode = (struct node *) mh_xmalloc (sizeof *newnode);
+    struct node *newnode;
 
     /* This inserts the new node at the beginning of m_defs because
        that doesn't require traversing it or checking to see if it's
        empty. */
 
     /* This inserts the new node at the beginning of m_defs because
        that doesn't require traversing it or checking to see if it's
        empty. */
+    NEW(newnode);
     newnode->n_name = getcpy (key);
     newnode->n_field = getcpy (value);
     newnode->n_context = 0;
     newnode->n_name = getcpy (key);
     newnode->n_field = getcpy (value);
     newnode->n_context = 0;
index 10058d4da1e8df45c015eeb955ddf57021fecad3..d243f353486d50c86522e4baa43a9edbb0556f53 100644 (file)
@@ -46,8 +46,11 @@ static void bvector_resize (bvector_t, size_t);
 
 bvector_t
 bvector_create (size_t init_size) {
 
 bvector_t
 bvector_create (size_t init_size) {
-    bvector_t vec = mh_xmalloc (sizeof *vec);
-    size_t bytes = BVEC_BYTES (vec, init_size  ?  init_size  :  VEC_INIT_SIZE);
+    bvector_t vec;
+    size_t bytes;
+
+    NEW(vec);
+    bytes = BVEC_BYTES (vec, init_size  ?  init_size  :  VEC_INIT_SIZE);
 
     vec->bits = mh_xmalloc (bytes);
     memset (vec->bits, 0, bytes);
 
     vec->bits = mh_xmalloc (bytes);
     memset (vec->bits, 0, bytes);
@@ -144,9 +147,10 @@ static void svector_resize (svector_t, size_t);
 
 svector_t
 svector_create (size_t init_size) {
 
 svector_t
 svector_create (size_t init_size) {
-    svector_t vec = mh_xmalloc (sizeof *vec);
+    svector_t vec;
     size_t bytes;
 
     size_t bytes;
 
+    NEW(vec);
     vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
     bytes = vec->maxsize * sizeof (char *);
     vec->strs = mh_xmalloc (bytes);
     vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
     bytes = vec->maxsize * sizeof (char *);
     vec->strs = mh_xmalloc (bytes);
@@ -223,9 +227,10 @@ static void ivector_resize (ivector_t, size_t);
 
 ivector_t
 ivector_create (size_t init_size) {
 
 ivector_t
 ivector_create (size_t init_size) {
-    ivector_t vec = mh_xmalloc (sizeof *vec);
+    ivector_t vec;
     size_t bytes;
 
     size_t bytes;
 
+    NEW(vec);
     vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
     bytes = vec->maxsize * sizeof (int);
     vec->ints = mh_xmalloc (bytes);
     vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
     bytes = vec->maxsize * sizeof (int);
     vec->ints = mh_xmalloc (bytes);
index 0f6b1909bc38ea16f224bb09c40014f9afc61283..65cd5e445311d94511e54d9a2714db348c172422 100644 (file)
@@ -478,7 +478,7 @@ add_aka (struct aka *ak, char *pp)
        if (!strcmp (pp, ad->ad_text))
            return;
 
        if (!strcmp (pp, ad->ad_text))
            return;
 
-    ad = (struct adr *) mh_xmalloc (sizeof(*ad));
+    NEW(ad);
     ad->ad_text = getcpy (pp);
     ad->ad_local = strchr(pp, '@') == NULL && strchr(pp, '!') == NULL;
     ad->ad_next = NULL;
     ad->ad_text = getcpy (pp);
     ad->ad_local = strchr(pp, '@') == NULL && strchr(pp, '!') == NULL;
     ad->ad_next = NULL;
@@ -519,8 +519,7 @@ akalloc (char *id)
 {
     register struct aka *p;
 
 {
     register struct aka *p;
 
-    p = (struct aka *) mh_xmalloc (sizeof(*p));
-
+    NEW(p);
     p->ak_name = getcpy (id);
     p->ak_visible = 0;
     p->ak_addr = NULL;
     p->ak_name = getcpy (id);
     p->ak_visible = 0;
     p->ak_addr = NULL;
@@ -540,8 +539,7 @@ hmalloc (struct passwd *pw)
 {
     register struct home *p;
 
 {
     register struct home *p;
 
-    p = (struct home *) mh_xmalloc (sizeof(*p));
-
+    NEW(p);
     p->h_name = getcpy (pw->pw_name);
     p->h_uid = pw->pw_uid;
     p->h_gid = pw->pw_gid;
     p->h_name = getcpy (pw->pw_name);
     p->h_uid = pw->pw_uid;
     p->h_gid = pw->pw_gid;
index 5d7e19309fa29be21ea14c1d8d5689b072a7ee33..d6026b95db0b9f4871499d7ed75c74d5781646ca 100644 (file)
@@ -351,7 +351,7 @@ main (int argc, char **argv)
        if (trace) {
            struct trace_context *ctx;
 
        if (trace) {
            struct trace_context *ctx;
 
-           ctx = mh_xmalloc(sizeof(*ctx));
+           NEW(ctx);
            ctx->num = -1;
            ctx->str = dummy;
            ctx->outbuf = getcpy(NULL);
            ctx->num = -1;
            ctx->str = dummy;
            ctx->outbuf = getcpy(NULL);
index 6b8f4442632fd00b6f84b39c7e85a131c3f1ca68..a79793f5a36ce613474e8fdcbd75ee172b457254 100644 (file)
@@ -180,8 +180,8 @@ query:
     /*
      * Add some initial elements to the profile/context list
      */
     /*
      * Add some initial elements to the profile/context list
      */
-    m_defs = (struct node *) mh_xmalloc (sizeof *np);
-    np = m_defs;
+    NEW(np);
+    m_defs = np;
     np->n_name = getcpy ("Path");
     np->n_field = getcpy (pathname);
     np->n_context = 0;
     np->n_name = getcpy ("Path");
     np->n_field = getcpy (pathname);
     np->n_context = 0;
index eb899d25d4866ce27f96d99dc10e2737be9498bb..e867824fce100f95681f6db789cd5532ab0cba89 100644 (file)
@@ -243,7 +243,7 @@ build_mime (char *infile, int autobuild, int dist, int directives,
                    goto finish_field;
                }
 
                    goto finish_field;
                }
 
-               entry = mh_xmalloc(sizeof(*entry));
+               NEW(entry);
                entry->filename = getcpy(s);
                entry->next = NULL;
                free(vp);
                entry->filename = getcpy(s);
                entry->next = NULL;
                free(vp);
index 33faf468b93df553d18f1ec63e3a3e54456c5154..e9ed4fc91197a5c710c1bfa41f1fc6c90784cb3c 100644 (file)
@@ -1078,8 +1078,9 @@ fix_composite_cte (CT ct, int *message_mods) {
                 if (! strncasecmp (name, ENCODING_FIELD,
                                    strlen (ENCODING_FIELD))) {
                     char *prefix = "Nmh-REPLACED-INVALID-";
                 if (! strncasecmp (name, ENCODING_FIELD,
                                    strlen (ENCODING_FIELD))) {
                     char *prefix = "Nmh-REPLACED-INVALID-";
-                    HF h = mh_xmalloc (sizeof *h);
+                    HF h;
 
 
+                    NEW(h);
                     h->name = add (hf->name, NULL);
                     h->hf_encoding = hf->hf_encoding;
                     h->next = hf->next;
                     h->name = add (hf->name, NULL);
                     h->hf_encoding = hf->hf_encoding;
                     h->next = hf->next;
@@ -1395,8 +1396,9 @@ find_textplain_sibling (CT parent, int replacetextplain,
 static int
 insert_new_text_plain_part (CT ct, int new_subpart_number, CT parent) {
     struct multipart *mp = (struct multipart *) parent->c_ctparams;
 static int
 insert_new_text_plain_part (CT ct, int new_subpart_number, CT parent) {
     struct multipart *mp = (struct multipart *) parent->c_ctparams;
-    struct part *new_part = mh_xmalloc (sizeof *new_part);
+    struct part *new_part;
 
 
+    NEW(new_part);
     if ((new_part->mp_part = build_text_plain_part (ct))) {
         char buffer[16];
         snprintf (buffer, sizeof buffer, "%d", new_subpart_number);
     if ((new_part->mp_part = build_text_plain_part (ct))) {
         char buffer[16];
         snprintf (buffer, sizeof buffer, "%d", new_subpart_number);
@@ -1758,8 +1760,8 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) {
     add_param(&ct->c_ctinfo.ci_first_pm, &ct->c_ctinfo.ci_last_pm,
               "boundary", boundary, 0);
 
     add_param(&ct->c_ctinfo.ci_first_pm, &ct->c_ctinfo.ci_last_pm,
               "boundary", boundary, 0);
 
-    p = (struct part *) mh_xmalloc (sizeof *p);
-    p->mp_next = (struct part *) mh_xmalloc (sizeof *p->mp_next);
+    NEW(p);
+    NEW(p->mp_next);
     p->mp_next->mp_next = NULL;
     p->mp_next->mp_part = first_alt;
 
     p->mp_next->mp_next = NULL;
     p->mp_next->mp_part = first_alt;
 
index f43fd4945db8a54e6fe325da1f8f2355c8acbcb1..49c1aba6f22359aceacfdcf64e7321caefbd6038 100644 (file)
@@ -581,7 +581,7 @@ add_header (CT ct, char *name, char *value)
     HF hp;
 
     /* allocate header field structure */
     HF hp;
 
     /* allocate header field structure */
-    hp = mh_xmalloc (sizeof(*hp));
+    NEW(hp);
 
     /* link data into header structure */
     hp->name = name;
 
     /* link data into header structure */
     hp->name = name;
@@ -3537,7 +3537,7 @@ bad_quote:
            }
 
            if (pp == NULL) {
            }
 
            if (pp == NULL) {
-               pp = mh_xmalloc(sizeof(*pp));
+               NEW(pp);
                memset(pp, 0, sizeof(*pp));
                pp->name = nameptr;
                pp->next = phead;
                memset(pp, 0, sizeof(*pp));
                pp->name = nameptr;
                pp->next = phead;
@@ -3548,7 +3548,7 @@ bad_quote:
             * Insert this into the section linked list
             */
 
             * Insert this into the section linked list
             */
 
-           sp = mh_xmalloc(sizeof(*sp));
+           NEW(sp);
            memset(sp, 0, sizeof(*sp));
            sp->value = valptr;
            sp->index = index;
            memset(sp, 0, sizeof(*sp));
            sp->value = valptr;
            sp->index = index;
@@ -4082,10 +4082,10 @@ normal_param(PM pm, char *output, size_t len, size_t valuelen,
 PM
 add_param(PM *first, PM *last, char *name, char *value, int nocopy)
 {
 PM
 add_param(PM *first, PM *last, char *name, char *value, int nocopy)
 {
-    PM pm = mh_xmalloc(sizeof(*pm));
+    PM pm;
 
 
+    NEW(pm);
     memset(pm, 0, sizeof(*pm));
     memset(pm, 0, sizeof(*pm));
-
     pm->pm_name = nocopy ? name : getcpy(name);
     pm->pm_value = nocopy ? value : getcpy(value);
 
     pm->pm_name = nocopy ? name : getcpy(name);
     pm->pm_value = nocopy ? value : getcpy(value);
 
index 093c97767042c7d1251026c4e792fc5d28359af2..57ea78820069096febd67b193a5a4b76aa21a2b9 100644 (file)
@@ -1359,14 +1359,14 @@ compile_marker(char *form)
            dispo_comp = comp;
        } else if (strncasecmp(comp->c_name, "ctype-", 6) == 0 &&
                   strlen(comp->c_name) > 6) {
            dispo_comp = comp;
        } else if (strncasecmp(comp->c_name, "ctype-", 6) == 0 &&
                   strlen(comp->c_name) > 6) {
-           pc_entry = mh_xmalloc(sizeof(*pc_entry));
+           NEW(pc_entry);
            pc_entry->param = getcpy(comp->c_name + 6);
            pc_entry->comp = comp;
            pc_entry->next = ctype_pc_list;
            ctype_pc_list = pc_entry;
        } else if (strncasecmp(comp->c_name, "cdispo-", 7) == 0 &&
                   strlen(comp->c_name) > 7) {
            pc_entry->param = getcpy(comp->c_name + 6);
            pc_entry->comp = comp;
            pc_entry->next = ctype_pc_list;
            ctype_pc_list = pc_entry;
        } else if (strncasecmp(comp->c_name, "cdispo-", 7) == 0 &&
                   strlen(comp->c_name) > 7) {
-           pc_entry = mh_xmalloc(sizeof(*pc_entry));
+           NEW(pc_entry);
            pc_entry->param = getcpy(comp->c_name + 7);
            pc_entry->comp = comp;
            pc_entry->next = dispo_pc_list;
            pc_entry->param = getcpy(comp->c_name + 7);
            pc_entry->comp = comp;
            pc_entry->next = dispo_pc_list;
index 460eac28e65314e5d75256ed34c971950bd072b1..9869914be1c3ccb5feba5fe4223a5b857a0d9be8 100644 (file)
@@ -42,8 +42,9 @@ struct mhstoreinfo {
 
 mhstoreinfo_t
 mhstoreinfo_create (CT *ct, char *pwd, const char *csw, int asw, int vsw) {
 
 mhstoreinfo_t
 mhstoreinfo_create (CT *ct, char *pwd, const char *csw, int asw, int vsw) {
-    mhstoreinfo_t info = mh_xmalloc (sizeof *info);
+    mhstoreinfo_t info;
 
 
+    NEW(info);
     info->cts = ct;
     info->cwd = pwd;
     info->autosw = asw;
     info->cts = ct;
     info->cwd = pwd;
     info->autosw = asw;
index 9a7f9d4f2bdc76fe4060ddf6db0a983964f4c555..a8ee075e0e1ac0729a87e57cd1d31a346de6e7ad 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -201,9 +201,10 @@ check_folder(char *folder, size_t len, struct list_state *b)
 
     if (is_cur || msgnums != NULL) {
        if (*b->first == NULL) {
 
     if (is_cur || msgnums != NULL) {
        if (*b->first == NULL) {
-           *b->first = b->node = mh_xmalloc(sizeof(*b->node));
+           NEW(b->node);
+           *b->first = b->node;
        } else {
        } else {
-           b->node->n_next = mh_xmalloc(sizeof(*b->node));
+           NEW(b->node->n_next);
            b->node = b->node->n_next;
        }
        b->node->n_name = folder;
            b->node = b->node->n_next;
        }
        b->node->n_name = folder;
index 6380884c50262233d9e4dffaa4d82f1531fdc93c..983fd28b767843e8bf6c86b8739ad19b45b6cd60 100644 (file)
@@ -516,10 +516,11 @@ fix_addresses (char *str) {
          * local part.
          */
         while ((cp = getname (str))) {
          * local part.
          */
         while ((cp = getname (str))) {
-            struct adr_node *adr_nodep = mh_xmalloc (sizeof *adr_nodep);
+            struct adr_node *adr_nodep;
             char error[BUFSIZ];
             struct mailname *mp;
 
             char error[BUFSIZ];
             struct mailname *mp;
 
+            NEW(adr_nodep);
             adr_nodep->adr = strdup (cp);
             adr_nodep->escape_local_part = 0;
             adr_nodep->fixed = 0;
             adr_nodep->adr = strdup (cp);
             adr_nodep->escape_local_part = 0;
             adr_nodep->fixed = 0;