Merge "astobj2: Reduce memory overhead." into 13

This commit is contained in:
Joshua Colp
2018-10-01 09:07:07 -05:00
committed by Gerrit Code Review

View File

@@ -54,20 +54,21 @@ static FILE *ref_log;
* The magic number is used for consistency check. * The magic number is used for consistency check.
*/ */
struct __priv_data { struct __priv_data {
int ref_counter;
ao2_destructor_fn destructor_fn; ao2_destructor_fn destructor_fn;
#if defined(AO2_DEBUG) #if defined(AO2_DEBUG)
/*! User data size for stats */ /*! User data size for stats */
size_t data_size; size_t data_size;
#endif #endif
/*! Number of references held for this object */
int ref_counter;
/*! The ao2 object option flags */ /*! The ao2 object option flags */
uint32_t options; uint32_t options:2;
/*! magic number. This is used to verify that a pointer passed in is a /*! magic number. This is used to verify that a pointer passed in is a
* valid astobj2 */ * valid astobj2 */
uint32_t magic; uint32_t magic:30;
}; };
#define AO2_MAGIC 0xa570b123 #define AO2_MAGIC 0x3a70b123
/*! /*!
* What an astobj2 object looks like: fixed-size private data * What an astobj2 object looks like: fixed-size private data
@@ -587,8 +588,8 @@ static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_f
} }
/* Initialize common ao2 values. */ /* Initialize common ao2 values. */
obj->priv_data.ref_counter = 1;
obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */ obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */
obj->priv_data.ref_counter = 1;
obj->priv_data.options = options; obj->priv_data.options = options;
obj->priv_data.magic = AO2_MAGIC; obj->priv_data.magic = AO2_MAGIC;