[API] blob: move user_data before destroy()

This is the common convention for language binding tools.
This commit is contained in:
Behdad Esfahbod 2011-04-20 02:59:28 -04:00
parent 1fd73b594d
commit e5847f75fb
3 changed files with 11 additions and 11 deletions

View File

@ -47,8 +47,8 @@ struct _hb_blob_t {
const char *data; const char *data;
hb_destroy_func_t destroy;
void *user_data; void *user_data;
hb_destroy_func_t destroy;
}; };
extern HB_INTERNAL hb_blob_t _hb_blob_nil; extern HB_INTERNAL hb_blob_t _hb_blob_nil;

View File

@ -57,8 +57,8 @@ hb_blob_t _hb_blob_nil = {
NULL, /* data */ NULL, /* data */
NULL, /* destroy */ NULL, /* user_data */
NULL /* user_data */ NULL /* destroy */
}; };
static void static void
@ -66,8 +66,8 @@ _hb_blob_destroy_user_data (hb_blob_t *blob)
{ {
if (blob->destroy) { if (blob->destroy) {
blob->destroy (blob->user_data); blob->destroy (blob->user_data);
blob->destroy = NULL;
blob->user_data = NULL; blob->user_data = NULL;
blob->destroy = NULL;
} }
} }
@ -82,8 +82,8 @@ hb_blob_t *
hb_blob_create (const char *data, hb_blob_create (const char *data,
unsigned int length, unsigned int length,
hb_memory_mode_t mode, hb_memory_mode_t mode,
hb_destroy_func_t destroy, void *user_data,
void *user_data) hb_destroy_func_t destroy)
{ {
hb_blob_t *blob; hb_blob_t *blob;
@ -100,8 +100,8 @@ hb_blob_create (const char *data,
blob->length = length; blob->length = length;
blob->mode = mode; blob->mode = mode;
blob->destroy = destroy;
blob->user_data = user_data; blob->user_data = user_data;
blob->destroy = destroy;
if (blob->mode == HB_MEMORY_MODE_DUPLICATE) { if (blob->mode == HB_MEMORY_MODE_DUPLICATE) {
blob->mode = HB_MEMORY_MODE_READONLY; blob->mode = HB_MEMORY_MODE_READONLY;
@ -134,8 +134,8 @@ hb_blob_create_sub_blob (hb_blob_t *parent,
blob->mode = parent->mode; blob->mode = parent->mode;
hb_mutex_unlock (parent->lock); hb_mutex_unlock (parent->lock);
blob->destroy = (hb_destroy_func_t) _hb_blob_unlock_and_destroy;
blob->user_data = hb_blob_reference (parent); blob->user_data = hb_blob_reference (parent);
blob->destroy = (hb_destroy_func_t) _hb_blob_unlock_and_destroy;
return blob; return blob;
} }
@ -345,8 +345,8 @@ hb_blob_try_writable (hb_blob_t *blob)
_hb_blob_destroy_user_data (blob); _hb_blob_destroy_user_data (blob);
blob->mode = HB_MEMORY_MODE_WRITABLE; blob->mode = HB_MEMORY_MODE_WRITABLE;
blob->data = new_data; blob->data = new_data;
blob->destroy = free;
blob->user_data = new_data; blob->user_data = new_data;
blob->destroy = free;
} }
} }

View File

@ -45,8 +45,8 @@ hb_blob_t *
hb_blob_create (const char *data, hb_blob_create (const char *data,
unsigned int length, unsigned int length,
hb_memory_mode_t mode, hb_memory_mode_t mode,
hb_destroy_func_t destroy, void *user_data,
void *user_data); hb_destroy_func_t destroy);
hb_blob_t * hb_blob_t *
hb_blob_create_sub_blob (hb_blob_t *parent, hb_blob_create_sub_blob (hb_blob_t *parent,