diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-02-27 23:32:01 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2023-03-01 17:53:27 +1100 |
commit | 4718189c4ca83ddaa38a4990bddd1d4196b11933 (patch) | |
tree | da1263ab3002423a5b51bb6c6ffbc2f6736c54e1 /TODO | |
parent | 0b842c3c819971cdbe0915469759c40f6eb3db7e (diff) | |
download | dtc-4718189c4ca83ddaa38a4990bddd1d4196b11933.zip dtc-4718189c4ca83ddaa38a4990bddd1d4196b11933.tar.gz dtc-4718189c4ca83ddaa38a4990bddd1d4196b11933.tar.bz2 |
Delay xstrdup() of node and property names coming from a flat tree
The 'name' field of 'struct node' is supposed to be an (individually)
malloc()ed string. So, when taking a name from a flattened blob we need
to strdup() it.
Currently that happens in flat_read_string() as we take it from the
flattened structure itself. That obscures what's going on because it's
several steps removed from actually inserting it into node->name. It also
means we need an additional strdup() and free() for the case of old dtb
formats where we need to extract just the final path component from the
blob for the name.
While we're scanning the blob, we're doing so read-only, so it's fine to
have pointers into it. Therefore simplify things a bit by delaying the
xstrdup() to the point where we're actually inserting into node->name.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'TODO')
0 files changed, 0 insertions, 0 deletions