Source-Changes-HG archive

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

[src/trunk]: src/lib/libform When buffers are created they are given an empty...



details:   https://anonhg.NetBSD.org/src/rev/c7e1d4d7df64
branches:  trunk
changeset: 503054:c7e1d4d7df64
user:      blymn <blymn%NetBSD.org@localhost>
date:      Tue Jan 30 06:33:51 2001 +0000

description:
When buffers are created they are given an empty string instead of just
being set to NULL.  Stops us returning a NULL pointer for buffers that
are never set.

diffstat:

 lib/libform/field.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (27 lines):

diff -r f7eef2ca0912 -r c7e1d4d7df64 lib/libform/field.c
--- a/lib/libform/field.c       Tue Jan 30 04:15:10 2001 +0000
+++ b/lib/libform/field.c       Tue Jan 30 06:33:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: field.c,v 1.3 2001/01/16 01:02:47 blymn Exp $  */
+/*     $NetBSD: field.c,v 1.4 2001/01/30 06:33:51 blymn Exp $  */
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
  *                         (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -529,11 +529,14 @@
                return NULL;
        }
 
-         /* Initialise the string pointers... */
+         /* Initialise the strings to a zero length string */
        for (i = 0; i < nbuf + 1; i++) {
-               new->buffers[i].string = NULL;
+               if ((new->buffers[i].string =
+                    (char *) malloc(sizeof(char))) == NULL)
+                       return NULL;
+               new->buffers[i].string[0] = '\0';
                new->buffers[i].length = 0;
-               
+               new->buffers[i].allocated = 1;
        }
        
        return new;



Home | Main Index | Thread Index | Old Index