Browse Source

dtc: Abolish asize field of struct data

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>
main
David Gibson 17 years ago committed by Jon Loeliger
parent
commit
1a9468c9a0
  1. 8
      data.c
  2. 1
      dtc.h

8
data.c

@ -32,8 +32,6 @@ void data_free(struct data d)
m = nm; m = nm;
} }


assert(!d.val || d.asize);

if (d.val) if (d.val)
free(d.val); free(d.val);
} }
@ -43,9 +41,6 @@ struct data data_grow_for(struct data d, int xlen)
struct data nd; struct data nd;
int newsize; int newsize;


/* we must start with an allocated datum */
assert(!d.val || d.asize);

if (xlen == 0) if (xlen == 0)
return d; return d;


@ -56,11 +51,8 @@ struct data data_grow_for(struct data d, int xlen)
while ((d.len + xlen) > newsize) while ((d.len + xlen) > newsize)
newsize *= 2; newsize *= 2;


nd.asize = newsize;
nd.val = xrealloc(d.val, newsize); nd.val = xrealloc(d.val, newsize);


assert(nd.asize >= (d.len + xlen));

return nd; return nd;
} }



1
dtc.h

@ -118,7 +118,6 @@ struct marker {
struct data { struct data {
int len; int len;
char *val; char *val;
int asize;
struct marker *markers; struct marker *markers;
}; };



Loading…
Cancel
Save