From: Corey Farrell Date: Sat, 29 Oct 2016 15:31:15 +0000 (-0400) Subject: astobj2: Declare private variable data_size for AO2_DEBUG only. X-Git-Tag: 13.13.0-rc1~61^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fchanges%2F33%2F4233%2F1;p=thirdparty%2Fasterisk.git astobj2: Declare private variable data_size for AO2_DEBUG only. Every ao2 object contains storage for a private variable data_size, though the value is never read if AO2_DEBUG is disabled. This change makes the variable conditional, reducing memory usage. ASTERISK-26524 #close Change-Id: If859929e507676ebc58b0f84247a4231e11da07f --- diff --git a/main/astobj2.c b/main/astobj2.c index f5175ea153..7320c5efbd 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -52,8 +52,10 @@ static FILE *ref_log; struct __priv_data { int ref_counter; ao2_destructor_fn destructor_fn; +#if defined(AO2_DEBUG) /*! User data size for stats */ size_t data_size; +#endif /*! The ao2 object option flags */ uint32_t options; /*! magic number. This is used to verify that a pointer passed in is a @@ -570,11 +572,11 @@ static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_f /* Initialize common ao2 values. */ obj->priv_data.ref_counter = 1; obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */ - obj->priv_data.data_size = data_size; obj->priv_data.options = options; obj->priv_data.magic = AO2_MAGIC; #ifdef AO2_DEBUG + obj->priv_data.data_size = data_size; ast_atomic_fetchadd_int(&ao2.total_objects, 1); ast_atomic_fetchadd_int(&ao2.total_mem, data_size); ast_atomic_fetchadd_int(&ao2.total_refs, 1);