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) @@ -32,8 +32,6 @@ void data_free(struct data d)
m = nm;
}

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

if (d.val)
free(d.val);
}
@ -43,9 +41,6 @@ struct data data_grow_for(struct data d, int xlen) @@ -43,9 +41,6 @@ struct data data_grow_for(struct data d, int xlen)
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 @@ struct data data_grow_for(struct data d, int xlen) @@ -56,11 +51,8 @@ struct data data_grow_for(struct data d, int xlen)
while ((d.len + xlen) > newsize)
newsize *= 2;

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

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

return nd;
}


1
dtc.h

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


Loading…
Cancel
Save