diff options
author | jkh <jkh@FreeBSD.org> | 1995-10-20 07:02:53 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-10-20 07:02:53 +0000 |
commit | 5cfb4aca37c8d842868ccced836b0e293a8260f8 (patch) | |
tree | d0bbe996087ac38c98f38a01606670bbfa61e870 /usr.sbin/sysinstall/index.c | |
parent | dc58fb65bda5943581853112c9762c96a1eb3f9c (diff) | |
download | FreeBSD-src-5cfb4aca37c8d842868ccced836b0e293a8260f8.zip FreeBSD-src-5cfb4aca37c8d842868ccced836b0e293a8260f8.tar.gz |
Too many bugs fixed to mention. This code just seems to BREED them.
Many interfaces were also simplified or generally cleaned up in an
attempt to curb this problem.
Diffstat (limited to 'usr.sbin/sysinstall/index.c')
-rw-r--r-- | usr.sbin/sysinstall/index.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/usr.sbin/sysinstall/index.c b/usr.sbin/sysinstall/index.c index 3965653..2b5080c 100644 --- a/usr.sbin/sysinstall/index.c +++ b/usr.sbin/sysinstall/index.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: index.c,v 1.9 1995/10/16 09:25:13 jkh Exp $ + * $Id: index.c,v 1.10 1995/10/16 15:14:03 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -60,8 +60,7 @@ _strdup(char *ptr) } static char *descrs[] = { - "Package Selection", - "To select a package or category, move to it and press SPACE.\n" + "Package Selection", "To select a package or category, move to it and press SPACE.\n" "To remove a package from consideration, press SPACE again.\n" "To go to a previous menu, select UP item or Cancel. To search\n" "for a package by name, press ESC.", @@ -126,13 +125,8 @@ fetch_desc(char *name) static PkgNodePtr new_pkg_node(char *name, node_type type) { - PkgNodePtr tmp = malloc(sizeof(PkgNode)); + PkgNodePtr tmp = safe_malloc(sizeof(PkgNode)); - if (!tmp) { - fprintf(stderr, "Out of memory - unable to allocate a new package node!\n"); - exit(1); - } - bzero(tmp, sizeof(PkgNode)); tmp->name = _strdup(name); tmp->type = type; return tmp; @@ -141,14 +135,8 @@ new_pkg_node(char *name, node_type type) static IndexEntryPtr new_index(char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint) { - IndexEntryPtr tmp = malloc(sizeof(IndexEntry)); - - if (!tmp) { - fprintf(stderr, "Out of memory - unable to allocate a new index node!\n"); - exit(1); - } + IndexEntryPtr tmp = safe_malloc(sizeof(IndexEntry)); - bzero(tmp, sizeof(IndexEntry)); tmp->name = _strdup(name); tmp->path = _strdup(pathto); tmp->prefix = _strdup(prefix); @@ -163,8 +151,14 @@ strchop(char *s1, char *s2, int len) { int len2; - len2 = strlen(s1); - if (len2 >= len) { + if (!s1) + return s1; + if (!s2) { + s1[0] = '\0'; + return s1; + } + len2 = strlen(s2); + if (len2 > len) { strncpy(s1, s2, len - 1); s1[len] = '\0'; } |