Revert "add free_field as standard for struct field"
[mmh] / sbr / m_getfld2.c
index 74d25e4..18ad812 100644 (file)
@@ -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;