Allow to use NULL as free function for image attached data.

release-1.5.4.branch
Vreixo Formoso 15 years ago
parent ec7fc7d1b2
commit ae004b1bfc
  1. 15
      libisofs/image.c
  2. 6
      libisofs/libisofs.h

@ -94,7 +94,7 @@ void iso_image_unref(IsoImage *image)
int nexcl;
/* we need to free the image */
if (image->user_data != NULL) {
if (image->user_data_free != NULL) {
/* free attached data */
image->user_data_free(image->user_data);
}
@ -129,12 +129,12 @@ void iso_image_unref(IsoImage *image)
* @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
* @param give_up
* 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.
* causes data to be free. It can be NULL if you don't need it.
*/
int iso_image_attach_data(IsoImage *image, void *data, void (*free)(void*))
int iso_image_attach_data(IsoImage *image, void *data, void (*give_up)(void*))
{
if (image == NULL || (data != NULL && free == NULL)) {
return ISO_NULL_POINTER;
@ -142,13 +142,16 @@ int iso_image_attach_data(IsoImage *image, void *data, void (*free)(void*))
if (image->user_data != NULL) {
/* free previously attached data */
image->user_data_free(image->user_data);
if (image->user_data_free) {
image->user_data_free(image->user_data);
}
image->user_data = NULL;
image->user_data_free = NULL;
}
if (data != NULL) {
image->user_data = data;
image->user_data_free = free;
image->user_data_free = give_up;
}
return ISO_SUCCESS;
}

@ -1344,16 +1344,16 @@ void iso_image_unref(IsoImage *image);
* @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
* @param give_up
* 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.
* causes data to be freed. It can be NULL if you don't need it.
* @return
* 1 on succes, < 0 on error
*
* @since 0.6.2
*/
int iso_image_attach_data(IsoImage *image, void *data, void (*free)(void*));
int iso_image_attach_data(IsoImage *image, void *data, void (*give_up)(void*));
/**
* The the data previously attached with iso_image_attach_data()

Loading…
Cancel
Save