diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-12-02 11:48:57 +0100 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-12-02 11:51:50 +0100 |
| commit | 9f19209c77b2131e89d3e7fb12771fb26ef491b3 (patch) | |
| tree | 54d2e66bff0cdf391803da76db03a78b25571a59 /utils/imxtools/sbtools/misc.c | |
| parent | a6713a5e3632523de67e2354799e4359efbc7773 (diff) | |
| download | rockbox-9f19209c77b2131e89d3e7fb12771fb26ef491b3.zip rockbox-9f19209c77b2131e89d3e7fb12771fb26ef491b3.tar.gz rockbox-9f19209c77b2131e89d3e7fb12771fb26ef491b3.tar.bz2 rockbox-9f19209c77b2131e89d3e7fb12771fb26ef491b3.tar.xz | |
rsrctool: produce an actually usuable entry list of the rsrc file
Change-Id: I6c8e5f3faf04741e4a13c1e705e9e869ccf8cfec
Diffstat (limited to 'utils/imxtools/sbtools/misc.c')
| -rw-r--r-- | utils/imxtools/sbtools/misc.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/utils/imxtools/sbtools/misc.c b/utils/imxtools/sbtools/misc.c index d88b2bc..dae4f92 100644 --- a/utils/imxtools/sbtools/misc.c +++ b/utils/imxtools/sbtools/misc.c @@ -84,6 +84,26 @@ void *augment_array(void *arr, size_t elem_sz, size_t cnt, void *aug, size_t aug return p; } +void augment_array_ex(void **arr, size_t elem_sz, int *cnt, int *capacity, + void *aug, int aug_cnt) +{ + /* if capacity is not large enough, double it */ + if(*cnt + aug_cnt > *capacity) + { + if(*capacity == 0) + *capacity = 1; + while(*cnt + aug_cnt > *capacity) + *capacity *= 2; + void *p = xmalloc(elem_sz * (*capacity)); + memcpy(p, *arr, elem_sz * (*cnt)); + free(*arr); + *arr = p; + } + /* copy elements */ + memcpy(*arr + elem_sz * (*cnt), aug, elem_sz * aug_cnt); + *cnt += aug_cnt; +} + /** * Key file parsing */ |