Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sbin/rcorder Pullup revision 1.6 (requested by thorpej):



details:   https://anonhg.NetBSD.org/src/rev/991fa6e65242
branches:  netbsd-1-5
changeset: 488624:991fa6e65242
user:      enami <enami%NetBSD.org@localhost>
date:      Sat Jul 22 01:45:39 2000 +0000

description:
Pullup revision 1.6 (requested by thorpej):
Free storage allocated by fparseln.

diffstat:

 sbin/rcorder/rcorder.c |  27 +++++++++++----------------
 1 files changed, 11 insertions(+), 16 deletions(-)

diffs (79 lines):

diff -r 4baec231d878 -r 991fa6e65242 sbin/rcorder/rcorder.c
--- a/sbin/rcorder/rcorder.c    Sat Jul 22 01:42:31 2000 +0000
+++ b/sbin/rcorder/rcorder.c    Sat Jul 22 01:45:39 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rcorder.c,v 1.4.4.1 2000/07/18 16:29:58 mrg Exp $      */
+/*     $NetBSD: rcorder.c,v 1.4.4.2 2000/07/22 01:45:39 enami Exp $    */
 
 /*
  * Copyright (c) 1998, 1999 Matthew R. Green
@@ -107,8 +107,8 @@
 
 struct strnodelist {
        filenode        *node;
-       char            *s;
        strnodelist     *next;
+       char            s[1];
 };
 
 struct filenode {
@@ -213,9 +213,9 @@
 {
        strnodelist *ent;
 
-       ent = emalloc(sizeof *ent);
+       ent = emalloc(sizeof *ent + strlen(s));
        ent->node = fnode;
-       ent->s = s;
+       strcpy(ent->s, s);
        ent->next = *listp;
        *listp = ent;
 }
@@ -369,9 +369,9 @@
 {
        strnodelist *bf_ent;
 
-       bf_ent = emalloc(sizeof *bf_ent);
+       bf_ent = emalloc(sizeof *bf_ent + strlen(s));
        bf_ent->node = fnode;
-       bf_ent->s = s;
+       strcpy(bf_ent->s, s);
        bf_ent->next = bl_list;
        bl_list = bf_ent;
 }
@@ -462,14 +462,11 @@
 {
        FILE *fp;
        char *buf;
-       int require_flag, provide_flag, before_flag, keywords_flag,
-           directive_flag;
+       int require_flag, provide_flag, before_flag, keywords_flag;
        filenode *node;
        char delims[3] = { '\\', '\\', '\0' };
        struct stat st;
 
-       directive_flag = 0;
-
        if ((fp = fopen(filename, "r")) == NULL) {
                warn("could not open %s", filename);
                return;
@@ -512,15 +509,13 @@
 
                if (require_flag)
                        parse_require(node, buf + require_flag);
-
-               if (provide_flag)
+               else if (provide_flag)
                        parse_provide(node, buf + provide_flag);
-
-               if (before_flag)
+               else if (before_flag)
                        parse_before(node, buf + before_flag);
-
-               if (keywords_flag)
+               else if (keywords_flag)
                        parse_keywords(node, buf + keywords_flag);
+               free(buf);
        }
        fclose(fp);
 }



Home | Main Index | Thread Index | Old Index