diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-01-15 00:50:41 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-01-15 01:07:20 +0900 |
commit | 696ccba690dc5a75cd3e9e3664292cfe24d16e5c (patch) | |
tree | 825e361fe1790ae3c455c6bfabcaf310da1085c0 /tools | |
parent | 44f1c0bdeda023d853e460d7c949c16647a01273 (diff) |
fiptool: introduce xzalloc() helper function
We often want to zero out allocated memory.
My main motivation for this commit is to set image::next and
image_desc::next to NULL automatically in the next commit.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/fiptool/fiptool.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c index fc0c8d66..4b91b1f9 100644 --- a/tools/fiptool/fiptool.c +++ b/tools/fiptool/fiptool.c @@ -155,12 +155,17 @@ static void *xmalloc(size_t size, const char *msg) return d; } +static void *xzalloc(size_t size, const char *msg) +{ + return memset(xmalloc(size, msg), 0, size); +} + static image_desc_t *new_image_desc(const uuid_t *uuid, const char *name, const char *cmdline_name) { image_desc_t *desc; - desc = xmalloc(sizeof(*desc), + desc = xzalloc(sizeof(*desc), "failed to allocate memory for image descriptor"); memcpy(&desc->uuid, uuid, sizeof(uuid_t)); desc->name = xstrdup(name, @@ -168,7 +173,6 @@ static image_desc_t *new_image_desc(const uuid_t *uuid, desc->cmdline_name = xstrdup(cmdline_name, "failed to allocate memory for image command line name"); desc->action = DO_UNSPEC; - desc->action_arg = NULL; return desc; } |