1
0
Fork 0
forked from len0rd/rockbox

rsrctool: produce an actually usuable entry list of the rsrc file

Change-Id: I6c8e5f3faf04741e4a13c1e705e9e869ccf8cfec
This commit is contained in:
Amaury Pouly 2012-12-02 11:48:57 +01:00
parent a6713a5e36
commit 9f19209c77
5 changed files with 73 additions and 14 deletions

View file

@ -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
*/