version 1.30, 2014/01/16 21:45:33 |
version 1.31, 2014/05/18 17:50:11 |
|
|
|
|
maxmagic = MAXMAGIS; |
maxmagic = MAXMAGIS; |
if ((marray = calloc(maxmagic, sizeof(*marray))) == NULL) { |
if ((marray = calloc(maxmagic, sizeof(*marray))) == NULL) { |
file_oomem(ms, maxmagic * sizeof(*marray)); |
file_oomem2(ms, maxmagic, sizeof(*marray)); |
return -1; |
return -1; |
} |
} |
marraycount = 0; |
marraycount = 0; |
|
|
for (i = 0; i < marraycount; i++) |
for (i = 0; i < marraycount; i++) |
mentrycount += marray[i].cont_count; |
mentrycount += marray[i].cont_count; |
|
|
if ((*magicp = malloc(sizeof(**magicp) * mentrycount)) == NULL) { |
if ((*magicp = reallocarray(NULL, mentrycount, sizeof(**magicp))) == NULL) { |
file_oomem(ms, sizeof(**magicp) * mentrycount); |
file_oomem2(ms, mentrycount, sizeof(**magicp)); |
errs++; |
errs++; |
goto out; |
goto out; |
} |
} |
|
|
if (me->cont_count == me->max_count) { |
if (me->cont_count == me->max_count) { |
struct magic *nm; |
struct magic *nm; |
size_t cnt = me->max_count + ALLOC_CHUNK; |
size_t cnt = me->max_count + ALLOC_CHUNK; |
if ((nm = realloc(me->mp, sizeof(*nm) * cnt)) == NULL) { |
if ((nm = reallocarray(me->mp, cnt, sizeof(*nm))) |
file_oomem(ms, sizeof(*nm) * cnt); |
== NULL) { |
|
file_oomem2(ms, cnt, sizeof(*nm)); |
return -1; |
return -1; |
} |
} |
me->mp = m = nm; |
me->mp = m = nm; |
|
|
struct magic_entry *mp; |
struct magic_entry *mp; |
|
|
maxmagic += ALLOC_INCR; |
maxmagic += ALLOC_INCR; |
if ((mp = realloc(*mentryp, sizeof(*mp) * maxmagic)) == |
if ((mp = reallocarray(*mentryp, maxmagic, |
NULL) { |
sizeof(*mp))) == NULL) { |
file_oomem(ms, sizeof(*mp) * maxmagic); |
file_oomem2(ms, maxmagic, sizeof(*mp)); |
return -1; |
return -1; |
} |
} |
(void)memset(&mp[*nmentryp], 0, sizeof(*mp) * |
(void)memset(&mp[*nmentryp], 0, sizeof(*mp) * |
|
|
} |
} |
me = &(*mentryp)[*nmentryp]; |
me = &(*mentryp)[*nmentryp]; |
if (me->mp == NULL) { |
if (me->mp == NULL) { |
if ((m = malloc(sizeof(*m) * ALLOC_CHUNK)) == NULL) { |
if ((m = reallocarray(NULL, ALLOC_CHUNK, sizeof(*m))) == NULL) { |
file_oomem(ms, sizeof(*m) * ALLOC_CHUNK); |
file_oomem2(ms, ALLOC_CHUNK, sizeof(*m)); |
return -1; |
return -1; |
} |
} |
me->mp = m; |
me->mp = m; |