summaryrefslogtreecommitdiffstats
path: root/release/sysinstall/attr.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-12-12 08:33:38 +0000
committerjkh <jkh@FreeBSD.org>1996-12-12 08:33:38 +0000
commit61be8f66cf7d37967637bc2fac3191f514c220de (patch)
treee55bd7f41e2d91b60c93866ae2102986a547ec2d /release/sysinstall/attr.c
parent29d7f1c31842286de505e626253394a7df40547d (diff)
downloadFreeBSD-src-61be8f66cf7d37967637bc2fac3191f514c220de.zip
FreeBSD-src-61be8f66cf7d37967637bc2fac3191f514c220de.tar.gz
Undo one of my memory optimization hacks - it actually made things more
complicated.
Diffstat (limited to 'release/sysinstall/attr.c')
-rw-r--r--release/sysinstall/attr.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/release/sysinstall/attr.c b/release/sysinstall/attr.c
index 2310d3c..10449e54 100644
--- a/release/sysinstall/attr.c
+++ b/release/sysinstall/attr.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: attr.c,v 1.10 1996/12/11 09:34:53 jkh Exp $
+ * $Id: attr.c,v 1.11 1996/12/11 18:23:16 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -137,23 +137,23 @@ attr_parse(Attribs *attr, FILE *fp)
break;
case COMMIT:
- attr[num_attribs].name = strdup(hold_n);
- attr[num_attribs].value = strdup(hold_v);
+ SAFE_STRCPY(attr[num_attribs].name, hold_n);
+ SAFE_STRCPY(attr[num_attribs].value, hold_v);
state = LOOK;
v = n = 0;
if (++num_attribs >= MAX_ATTRIBS)
msgFatal("Attribute limit overflow; encountered a bad attributes file!");
break;
-
+
default:
msgFatal("Unknown state at line %d??", lno);
}
}
- attr[num_attribs].name = NULL; /* end marker */
- attr[num_attribs].value = NULL; /* end marker */
+ attr[num_attribs].name[0] = NULL; /* end marker */
+ attr[num_attribs].value[0] = NULL; /* end marker */
if (isDebug())
msgDebug("Finished parsing %d attributes.\n", num_attribs);
-
+
return DITEM_SUCCESS;
}
@@ -165,7 +165,7 @@ attr_match(Attribs *attr, char *name)
if (isDebug())
msgDebug("Trying to match attribute `%s'\n", name);
- for (n = 0; attr[n].name && strcasecmp(attr[n].name, name) != 0; n++) {
+ for (n = 0; attr[n].name[0] && strcasecmp(attr[n].name, name) != 0; n++) {
if (isDebug())
msgDebug("Skipping attribute %u\n", n);
}
@@ -173,7 +173,7 @@ attr_match(Attribs *attr, char *name)
if (isDebug())
msgDebug("Stopped on attribute %u\n", n);
- if (attr[n].name) {
+ if (attr[n].name[0]) {
if (isDebug())
msgDebug("Returning `%s'\n", attr[n].value);
return(attr[n].value);
@@ -181,16 +181,3 @@ attr_match(Attribs *attr, char *name)
return NULL;
}
-
-void
-attr_free(Attribs *attr)
-{
- int i;
-
- for (i = 0; attr[i].name; i++) {
- free(attr[i].name);
- free(attr[i].value);
- attr[i].name = attr[i].value = NULL;
- }
- free(attr);
-}
OpenPOWER on IntegriCloud