|
|
|
@ -93,6 +93,10 @@ void iso_image_unref(IsoImage *image)
|
|
|
|
|
{
|
|
|
|
|
if (--image->refcount == 0) {
|
|
|
|
|
/* we need to free the image */
|
|
|
|
|
if (image->user_data != NULL) {
|
|
|
|
|
/* free attached data */
|
|
|
|
|
image->user_data_free(image->user_data);
|
|
|
|
|
}
|
|
|
|
|
iso_node_unref((IsoNode*)image->root);
|
|
|
|
|
iso_node_builder_unref(image->builder);
|
|
|
|
|
iso_filesystem_unref(image->fs);
|
|
|
|
@ -110,6 +114,46 @@ void iso_image_unref(IsoImage *image)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Attach user defined data to the image. Use this if your application needs
|
|
|
|
|
* to store addition info together with the IsoImage. If the image already
|
|
|
|
|
* has data attached, the old data will be freed.
|
|
|
|
|
*
|
|
|
|
|
* @param data
|
|
|
|
|
* Pointer to application defined data that will be attached to the
|
|
|
|
|
* image. You can pass NULL to remove any already attached data.
|
|
|
|
|
* @param free
|
|
|
|
|
* Function that will be called when the image does not need the data
|
|
|
|
|
* any more. It receives the data pointer as an argumente, and eventually
|
|
|
|
|
* causes data to be free.
|
|
|
|
|
*/
|
|
|
|
|
int iso_image_attach_data(IsoImage *image, void *data, void (*free)(void*))
|
|
|
|
|
{
|
|
|
|
|
if (image == NULL || (data != NULL && free == NULL)) {
|
|
|
|
|
return ISO_NULL_POINTER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (image->user_data != NULL) {
|
|
|
|
|
/* free previously attached data */
|
|
|
|
|
image->user_data_free(image->user_data);
|
|
|
|
|
image->user_data = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data != NULL) {
|
|
|
|
|
image->user_data = data;
|
|
|
|
|
image->user_data_free = free;
|
|
|
|
|
}
|
|
|
|
|
return ISO_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The the data previously attached with iso_image_attach_data()
|
|
|
|
|
*/
|
|
|
|
|
void *iso_image_get_attached_data(IsoImage *image)
|
|
|
|
|
{
|
|
|
|
|
return image->user_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsoDir *iso_image_get_root(const IsoImage *image)
|
|
|
|
|
{
|
|
|
|
|
return image->root;
|
|
|
|
|