*out_buffer = membuffer_detach(buf);
membuffer_free(buf);
return 1;
- } else {
- udta_offset = get_position(f);
- udta_size = read_int32(f);
- if (!find_atom_v2 (f, udta_offset + 8, udta_size - 8, "meta", 4, "ilst")) {
- struct membuffer *buf;
- void *new_meta_buffer;
- uint32_t new_meta_size;
-
- if (!create_meta(&f->meta, &new_meta_buffer, &new_meta_size))
- return 0;
-
- buf = membuffer_create();
- set_position(f, total_base);
- membuffer_transfer_from_file(buf, f,
- (uint32_t)(udta_offset - total_base));
-
- membuffer_write_int32(buf, udta_size + 8 + new_meta_size);
- membuffer_write_atom_name(buf, "udta");
- membuffer_transfer_from_file(buf, f, udta_size);
-
- membuffer_write_atom(buf, "meta", new_meta_size,
- new_meta_buffer);
- free(new_meta_buffer);
-
- *out_size = membuffer_get_size(buf);
- *out_buffer = membuffer_detach(buf);
- membuffer_free(buf);
- return 1;
- }
- meta_offset = get_position(f);
- meta_size = read_int32(f);
- if (!find_atom(f, meta_offset + 12, meta_size - 12, "ilst"))
- return 0; //shouldn't happen, find_atom_v2 above takes care of it
- ilst_offset = get_position(f);
- ilst_size = read_int32(f);
-
- if (!create_ilst(&f->meta, &new_ilst_buffer, &new_ilst_size))
+ }
+ udta_offset = get_position(f);
+ udta_size = read_int32(f);
+ if (!find_atom_v2 (f, udta_offset + 8, udta_size - 8, "meta", 4, "ilst")) {
+ struct membuffer *buf;
+ void *new_meta_buffer;
+ uint32_t new_meta_size;
+
+ if (!create_meta(&f->meta, &new_meta_buffer, &new_meta_size))
return 0;
- size_delta = new_ilst_size - (ilst_size - 8);
+ buf = membuffer_create();
+ set_position(f, total_base);
+ membuffer_transfer_from_file(buf, f,
+ (uint32_t)(udta_offset - total_base));
- *out_size = total_size + size_delta;
- *out_buffer = para_malloc(*out_size);
- p_out = (uint8_t *) * out_buffer;
+ membuffer_write_int32(buf, udta_size + 8 + new_meta_size);
+ membuffer_write_atom_name(buf, "udta");
+ membuffer_transfer_from_file(buf, f, udta_size);
- set_position(f, total_base);
- read_data(f, p_out,
- (uint32_t) (udta_offset - total_base));
- p_out += (uint32_t) (udta_offset - total_base);
- *(uint32_t *) p_out = fix_byte_order_32(read_int32(f) + size_delta);
- p_out += 4;
- read_data(f, p_out, 4);
- p_out += 4;
- read_data(f, p_out,
- (uint32_t) (meta_offset - udta_offset - 8));
- p_out += (uint32_t) (meta_offset - udta_offset - 8);
- *(uint32_t *) p_out = fix_byte_order_32(read_int32(f) + size_delta);
- p_out += 4;
- read_data(f, p_out, 4);
- p_out += 4;
- read_data(f, p_out,
- (uint32_t) (ilst_offset - meta_offset - 8));
- p_out += (uint32_t) (ilst_offset - meta_offset - 8);
- *(uint32_t *) p_out = fix_byte_order_32(read_int32(f) + size_delta);
- p_out += 4;
- read_data(f, p_out, 4);
- p_out += 4;
-
- memcpy(p_out, new_ilst_buffer, new_ilst_size);
- p_out += new_ilst_size;
-
- set_position(f, ilst_offset + ilst_size);
- read_data(f, p_out, (uint32_t) (total_size
- - (ilst_offset - total_base) - ilst_size));
-
- free(new_ilst_buffer);
+ membuffer_write_atom(buf, "meta", new_meta_size,
+ new_meta_buffer);
+ free(new_meta_buffer);
+
+ *out_size = membuffer_get_size(buf);
+ *out_buffer = membuffer_detach(buf);
+ membuffer_free(buf);
+ return 1;
}
+ meta_offset = get_position(f);
+ meta_size = read_int32(f);
+ if (!find_atom(f, meta_offset + 12, meta_size - 12, "ilst"))
+ return 0; /* shouldn't happen, find_atom_v2 above takes care of it */
+ ilst_offset = get_position(f);
+ ilst_size = read_int32(f);
+ if (!create_ilst(&f->meta, &new_ilst_buffer, &new_ilst_size))
+ return 0;
+ size_delta = new_ilst_size - (ilst_size - 8);
+ *out_size = total_size + size_delta;
+ *out_buffer = para_malloc(*out_size);
+ p_out = (uint8_t *)*out_buffer;
+ set_position(f, total_base);
+ read_data(f, p_out, (uint32_t) (udta_offset - total_base));
+ p_out += (uint32_t) (udta_offset - total_base);
+ *(uint32_t *)p_out = fix_byte_order_32(read_int32(f) + size_delta);
+ p_out += 4;
+ read_data(f, p_out, 4);
+ p_out += 4;
+ read_data(f, p_out, (uint32_t) (meta_offset - udta_offset - 8));
+ p_out += (uint32_t) (meta_offset - udta_offset - 8);
+ *(uint32_t *)p_out = fix_byte_order_32(read_int32(f) + size_delta);
+ p_out += 4;
+ read_data(f, p_out, 4);
+ p_out += 4;
+ read_data(f, p_out, (uint32_t) (ilst_offset - meta_offset - 8));
+ p_out += (uint32_t) (ilst_offset - meta_offset - 8);
+ *(uint32_t *)p_out = fix_byte_order_32(read_int32(f) + size_delta);
+ p_out += 4;
+ read_data(f, p_out, 4);
+ p_out += 4;
+ memcpy(p_out, new_ilst_buffer, new_ilst_size);
+ p_out += new_ilst_size;
+ set_position(f, ilst_offset + ilst_size);
+ read_data(f, p_out, (uint32_t) (total_size
+ - (ilst_offset - total_base) - ilst_size));
+ free(new_ilst_buffer);
return 1;
}