diff options
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 d88b2bc858..dae4f92121 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 | |||
84 | return p; | 84 | return p; |
85 | } | 85 | } |
86 | 86 | ||
87 | void augment_array_ex(void **arr, size_t elem_sz, int *cnt, int *capacity, | ||
88 | void *aug, int aug_cnt) | ||
89 | { | ||
90 | /* if capacity is not large enough, double it */ | ||
91 | if(*cnt + aug_cnt > *capacity) | ||
92 | { | ||
93 | if(*capacity == 0) | ||
94 | *capacity = 1; | ||
95 | while(*cnt + aug_cnt > *capacity) | ||
96 | *capacity *= 2; | ||
97 | void *p = xmalloc(elem_sz * (*capacity)); | ||
98 | memcpy(p, *arr, elem_sz * (*cnt)); | ||
99 | free(*arr); | ||
100 | *arr = p; | ||
101 | } | ||
102 | /* copy elements */ | ||
103 | memcpy(*arr + elem_sz * (*cnt), aug, elem_sz * aug_cnt); | ||
104 | *cnt += aug_cnt; | ||
105 | } | ||
106 | |||
87 | /** | 107 | /** |
88 | * Key file parsing | 108 | * Key file parsing |
89 | */ | 109 | */ |