linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* dtc: Abolish asize field of struct data
@ 2008-03-06  4:48 David Gibson
  0 siblings, 0 replies; only message in thread
From: David Gibson @ 2008-03-06  4:48 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

The asize field in struct data is a hangover from the early days when
a struct data was sometimes allowed to refer to a static chunk of
memory rather than a malloc()ed block.

That's long gone, since the lifetime issues were far more trouble than
it was worth, so get rid of the asize field.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Index: dtc/dtc.h
===================================================================
--- dtc.orig/dtc.h	2008-03-06 15:43:56.000000000 +1100
+++ dtc/dtc.h	2008-03-06 15:44:06.000000000 +1100
@@ -118,7 +118,6 @@
 struct data {
 	int len;
 	char *val;
-	int asize;
 	struct marker *markers;
 };
 
Index: dtc/data.c
===================================================================
--- dtc.orig/data.c	2008-03-06 15:44:27.000000000 +1100
+++ dtc/data.c	2008-03-06 15:45:01.000000000 +1100
@@ -32,8 +32,6 @@
 		m = nm;
 	}
 
-	assert(!d.val || d.asize);
-
 	if (d.val)
 		free(d.val);
 }
@@ -43,9 +41,6 @@
 	struct data nd;
 	int newsize;
 
-	/* we must start with an allocated datum */
-	assert(!d.val || d.asize);
-
 	if (xlen == 0)
 		return d;
 
@@ -56,11 +51,8 @@
 	while ((d.len + xlen) > newsize)
 		newsize *= 2;
 
-	nd.asize = newsize;
 	nd.val = xrealloc(d.val, newsize);
 
-	assert(nd.asize >= (d.len + xlen));
-
 	return nd;
 }
 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-03-06  4:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-06  4:48 dtc: Abolish asize field of struct data David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).