Skip to contentSkip to conversation

dtc: Abolish asize field of struct data

PATCH David Gibson 1 participant 1 message Mar 6, 2008

lore
Share & tools
lore
#0 lore raw

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.

dtc.h +0 -1
Index: dtc/dtc.h
===================================================================
@@ -118,7 +118,6 @@
 struct data {
 	int len;
 	char *val;
-	int asize;
 	struct marker *markers;
 };
 
data.c +0 -8
Index: dtc/data.c
===================================================================
@@ -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;
 }
 
Signature · 4 lines
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