From: Philipp Takacs Date: Sun, 13 Dec 2015 16:14:38 +0000 (+0100) Subject: Revert "add free_field as standard for struct field" X-Git-Tag: mmh-0.3~39^2~3 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=cdb32d069bdcb6fa04ca7e3d87240442665611b0 Revert "add free_field as standard for struct field" This is not necesary, because the compieler have to take care about NULL != (void*)0 This reverts commit a87df3543d3bc128ba4079d1f95638476ba5ca50. --- diff --git a/h/mh.h b/h/mh.h index 481f2f1..8f6fad1 100644 --- a/h/mh.h +++ b/h/mh.h @@ -212,8 +212,6 @@ struct field { size_t alloclen; }; -extern struct field free_field; - /* m_getfld2() states */ enum state { LENERR2 = -2, /* Line too long */ diff --git a/sbr/m_getfld2.c b/sbr/m_getfld2.c index 74d25e4..18ad812 100644 --- a/sbr/m_getfld2.c +++ b/sbr/m_getfld2.c @@ -26,8 +26,6 @@ static enum threestate is_falted(FILE *); static size_t copyname(char *, char *); static bool is_separator(char *); -struct field free_field = { "\0", 0, NULL, 0, 0 }; - /* ** FLD2: We read a (complete) header field @@ -57,7 +55,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg) nchars = getline(&tmpline, &len, msg); if (nchars < 1) { free(f->value); - *f = free_field; + *f = (struct field) { "\0", 0, NULL, 0, 0 }; if (feof(msg)) { return FILEEOF2; } else { @@ -132,12 +130,15 @@ m_getfld2(enum state s, struct field *f, FILE *msg) return ret; case BODY2: - free(f->value); - *f = free_field; + *f->name = '\0'; + f->namelen = 0; nchars = getline(&tmpline, &len, msg); if (nchars < 1) { - free(tmpline); + free(f->value); + f->value = NULL; + f->valuelen = 0; + f->alloclen = 0; if (feof(msg)) { return FILEEOF2; } else { @@ -149,6 +150,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg) ret = LENERR2; } + free(f->value); f->value = tmpline; f->valuelen = nchars; f->alloclen = len; diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 645a9ef..ccdf867 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -37,7 +37,7 @@ void readconfig(struct node **npp, FILE *ib, char *file, int ctx) { enum state state; - struct field f = free_field; + struct field f = {{0}}; struct node *np; struct procstr *ps; diff --git a/sbr/seq_read.c b/sbr/seq_read.c index 68351ac..1929b26 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -56,7 +56,7 @@ static void seq_public(struct msgs *mp) { enum state state; - struct field f = free_field; + struct field f = {{0}}; char seqfile[PATH_MAX]; FILE *fp; diff --git a/uip/distsbr.c b/uip/distsbr.c index 21b42a5..9c20fda 100644 --- a/uip/distsbr.c +++ b/uip/distsbr.c @@ -25,7 +25,7 @@ int distout(char *drft, char *msgnam, char *backup) { enum state state; - struct field f = free_field; + struct field f = {{0}}; unsigned char *dp; int resent = 0; FILE *ifp, *ofp; @@ -123,7 +123,7 @@ static int ready_msg(char *msgnam) { enum state state; - struct field f = free_field; + struct field f = {{0}}; char tmpfil[BUFSIZ]; int out; FILE *ifp, *ofp; diff --git a/uip/mhbuild.c b/uip/mhbuild.c index c4b1c60..ec5623a 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -313,7 +313,7 @@ static CT build_mime(char *infile) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int compnum; char buf[BUFSIZ]; char *cp, *np, *vp; diff --git a/uip/mhl.c b/uip/mhl.c index 20f5d31..8becba9 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -599,7 +599,7 @@ static void mhlfile(FILE *fp, char *mname, int ofilen, int ofilec) { enum state state; - struct field f = free_field; + struct field f = {{0}}; struct mcomp *c1, *c2, *c3; char **ip; diff --git a/uip/mhparse.c b/uip/mhparse.c index 04333f4..257bc66 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -232,7 +232,7 @@ static CT get_content(FILE *in, char *file, int toplevel) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int compnum; CT ct; HF hp; diff --git a/uip/new.c b/uip/new.c index 60bb806..a2be29b 100644 --- a/uip/new.c +++ b/uip/new.c @@ -96,7 +96,7 @@ static char * get_msgnums(char *folder, char *sequences[]) { enum state state; - struct field f = free_field; + struct field f = {{0}}; char *seqfile = concat(toabsdir(folder), "/", mh_seq, (void *)NULL); FILE *fp = fopen(seqfile, "r"); char *msgnums = NULL, *this_msgnums, *old_msgnums; diff --git a/uip/pick.c b/uip/pick.c index 03af15a..993527b 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -1242,7 +1242,7 @@ TWSaction(params) plist { enum state state; - struct field f = free_field; + struct field f = {{0}}; char *bp; struct tws *tw; diff --git a/uip/prompter.c b/uip/prompter.c index c715cb7..c7eb957 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -57,7 +57,7 @@ main(int argc, char **argv) int fdi, fdo, i; char *cp, *drft = NULL; enum state state; - struct field f = free_field; + struct field f = {{0}}; char buffer[BUFSIZ], tmpfil[BUFSIZ]; char **arguments, **argp; FILE *in, *out; diff --git a/uip/rcvdist.c b/uip/rcvdist.c index b54bc39..8292a20 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -154,7 +154,7 @@ rcvdistout(FILE *inb, char *form, char *addrs) { int char_read = 0, format_len, i; enum state state; - struct field f = free_field; + struct field f = {{0}}; char **ap; char *cp, *scanl; struct comp *cptr; diff --git a/uip/repl.c b/uip/repl.c index bbc3cfe..d71f27b 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -378,7 +378,7 @@ replout(FILE *inb, char *drft, struct msgs *mp, int mime, char *form, char *filter) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int i; struct comp *cptr; char **ap; diff --git a/uip/scansbr.c b/uip/scansbr.c index 8281c7b..50b250e 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -50,7 +50,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, static int slwidth; int compnum, i; enum state state; - struct field f = free_field; + struct field f = {{0}}; char *cp; struct comp *cptr; char *scnmsg = NULL; diff --git a/uip/slocal.c b/uip/slocal.c index 3b5007d..c3b45e8 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -725,7 +725,7 @@ static int parse(int fd) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int i, fd1; char *cp, *dp, *lp; struct pair *p, *q; diff --git a/uip/sortm.c b/uip/sortm.c index 6d45d35..61953e1 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -321,7 +321,7 @@ static int get_fields(char *datesw, int msg, struct smsg *smsg) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int compnum; char *msgnam; struct tws *tw; diff --git a/uip/spost.c b/uip/spost.c index b8ae562..04479a1 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int compnum; char *cp, *msg = NULL, **argp, **arguments; char **sargv, buf[BUFSIZ]; diff --git a/uip/whom.c b/uip/whom.c index c4e7e8f..a72c84f 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -204,7 +204,7 @@ static int process(char *file) { enum state state; - struct field f = free_field; + struct field f = {{0}}; int compnum; FILE *in;