static int32_t tag_add_field(struct mp4ff_metadata *tags, const char *item,
const char *value, int32_t len)
{
- void *backup = (void *) tags->tags;
-
if (!item || (item && !*item) || !value)
return 0;
- tags->tags = (struct mp4ff_tag *)realloc(tags->tags,
+ tags->tags = para_realloc(tags->tags,
(tags->count + 1) * sizeof(struct mp4ff_tag));
- if (!tags->tags) {
- free(backup);
- return 0;
+ tags->tags[tags->count].item = para_strdup(item);
+ tags->tags[tags->count].len = len;
+ if (len >= 0) {
+ tags->tags[tags->count].value = para_malloc(len + 1);
+ memcpy(tags->tags[tags->count].value, value, len);
+ tags->tags[tags->count].value[len] = 0;
} else {
- tags->tags[tags->count].item = para_strdup(item);
- tags->tags[tags->count].len = len;
- if (len >= 0) {
- tags->tags[tags->count].value = para_malloc(len + 1);
- memcpy(tags->tags[tags->count].value, value, len);
- tags->tags[tags->count].value[len] = 0;
- } else {
- tags->tags[tags->count].value = para_strdup(value);
- }
- tags->count++;
- return 1;
+ tags->tags[tags->count].value = para_strdup(value);
}
+ tags->count++;
+ return 1;
}
static const char *ID3v1GenreList[] = {
do {
buf->allocated <<= 1;
} while (dest_size > buf->allocated);
-
- {
- void *newptr = realloc(buf->data, buf->allocated);
- if (newptr == 0) {
- free(buf->data);
- buf->data = 0;
- buf->error = 1;
- return 0;
- }
- buf->data = newptr;
- }
+ buf->data = para_realloc(buf->data, buf->allocated);
}
if (ptr)
if (buf->error)
return 0;
-
- ret = realloc(buf->data, buf->written);
-
- if (ret == 0)
- free(buf->data);
-
+ ret = para_realloc(buf->data, buf->written);
buf->data = 0;
buf->error = 1;
-
return ret;
}