print_chunk_table(&afhi);
printf("\n");
}
- free(afhi.techinfo);
- free(afhi.tags.artist);
- free(afhi.tags.title);
- free(afhi.tags.year);
- free(afhi.tags.album);
- free(afhi.tags.comment);
- free(afhi.chunk_table);
+ clear_afhi(&afhi);
ret2 = para_munmap(audio_file_data, audio_file_size);
if (ret2 < 0 && ret >= 0)
ret = ret2;
void afh_get_header(struct afh_info *afhi, uint8_t audio_format_id,
void *map, size_t mapsize, char **buf, size_t *len);
void afh_free_header(char *header_buf, uint8_t audio_format_id);
+void clear_afhi(struct afh_info *afhi);
return ret;
}
+/**
+ * Deallocate contents of a filled-in ahi structure
+ *
+ * \param afhi The structure to clear.
+ *
+ * The given pointer is kept, everything else is freed.
+ */
+void clear_afhi(struct afh_info *afhi)
+{
+ if (!afhi)
+ return;
+ free(afhi->chunk_table);
+ free(afhi->techinfo);
+ free(afhi->tags.artist);
+ free(afhi->tags.title);
+ free(afhi->tags.year);
+ free(afhi->tags.album);
+ free(afhi->tags.comment);
+}
+
/**
* Get the name of the given audio format.
*
send_ret = sc_send_va_buffer(&pad->cc->scc,
"failed to add %s (%s)\n", path, para_strerror(-ret));
free(obj.data);
- if (afhi_ptr) {
- free(afhi_ptr->chunk_table);
- free(afhi_ptr->techinfo);
- free(afhi_ptr->tags.artist);
- free(afhi_ptr->tags.title);
- free(afhi_ptr->tags.year);
- free(afhi_ptr->tags.album);
- free(afhi_ptr->tags.comment);
- }
+ clear_afhi(afhi_ptr);
/* Stop adding files only on send errors. */
return send_ret;
}