<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10310">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">astobj2: Reduce memory overhead.<br><br>Reduce options to 2-bit field, magic to 30 bit field. Move ref_counter<br>next to options the fields will pack.<br><br>This reduces memory overhead for every ao2 object by 8 bytes on x86_64.<br><br>Change-Id: Idc1baabb35ec3b3d8de463c4fa3011eaf7fcafb5<br>---<br>M main/astobj2.c<br>1 file changed, 6 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/astobj2.c b/main/astobj2.c</span><br><span>index 147df7a..741bb64 100644</span><br><span>--- a/main/astobj2.c</span><br><span>+++ b/main/astobj2.c</span><br><span>@@ -50,20 +50,21 @@</span><br><span> * The magic number is used for consistency check.</span><br><span> */</span><br><span> struct __priv_data {</span><br><span style="color: hsl(0, 100%, 40%);">- int ref_counter;</span><br><span> ao2_destructor_fn destructor_fn;</span><br><span> #if defined(AO2_DEBUG)</span><br><span> /*! User data size for stats */</span><br><span> size_t data_size;</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Number of references held for this object */</span><br><span style="color: hsl(120, 100%, 40%);">+ int ref_counter;</span><br><span> /*! The ao2 object option flags */</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t options;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t options:2;</span><br><span> /*! magic number. This is used to verify that a pointer passed in is a</span><br><span> * valid astobj2 */</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t magic;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t magic:30;</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define AO2_MAGIC 0xa570b123</span><br><span style="color: hsl(120, 100%, 40%);">+#define AO2_MAGIC 0x3a70b123</span><br><span> </span><br><span> /*!</span><br><span> * What an astobj2 object looks like: fixed-size private data</span><br><span>@@ -583,8 +584,8 @@</span><br><span> }</span><br><span> </span><br><span> /* Initialize common ao2 values. */</span><br><span style="color: hsl(0, 100%, 40%);">- obj->priv_data.ref_counter = 1;</span><br><span> obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */</span><br><span style="color: hsl(120, 100%, 40%);">+ obj->priv_data.ref_counter = 1;</span><br><span> obj->priv_data.options = options;</span><br><span> obj->priv_data.magic = AO2_MAGIC;</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10310">change 10310</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10310"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Idc1baabb35ec3b3d8de463c4fa3011eaf7fcafb5 </div>
<div style="display:none"> Gerrit-Change-Number: 10310 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>