<p style="white-space: pre-wrap; word-wrap: break-word;">I don't want to discourage you, but I cannot help if something less generic might be upt to the task.  This quickly unfolds in tons of heap allocations and even more linear list traversals than I would normally like to see.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Wouldn't it also be an otpion to have a limited set (array) of 'entry' inside the use count itself?  That way we can avoid dynamic  allocations for every 'entry' and the linear list iterations on lookup.  And since the use_counter and all of its entries are then one big structure, that one could actually be statically part of a larger object of the user, avoiding any heap allocations at all?</p><p style="white-space: pre-wrap; word-wrap: break-word;">If you don't think it's possible to make a good fixed guess on the number of 'entries' (use counter buckets/classes is what I'd call them), then one could still make a compromise:  use a [0] sized array at the end of the counter, and once you allocate the counter, you pass in the number of entries/classes/buckets that shall be allocated as part of the counter?  That way we have dynamic number of entries at the expense of one heap allocation for the entire use_count?</p><p><a href="https://gerrit.osmocom.org/13121">View Change</a></p><p>2 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/13121/2/include/osmocom/core/use_count.h">File include/osmocom/core/use_count.h:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/13121/2/include/osmocom/core/use_count.h@133">Patch Set #2, Line 133:</a> <code style="font-family:monospace,monospace">talloc_object</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">naming issue: this is basically just some opaque void * pointer, right?  If nothing in the libosmocore use_count implementation actually treats this as 'talloc' object or context, then we should just call it 'priv', 'data', or 'user data'.  Uers may then choose to store a talloc context or whatever else they may want to store.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/13121/2/include/osmocom/core/use_count.h@150">Patch Set #2, Line 150:</a> <code style="font-family:monospace,monospace">count</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think it's rather difficult to understand that a given "entry" or "token" can have multiple "counts".  I understand that it's something that's handy in the context of osmo-msc and the "multiple CM service requests".</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/13121">change 13121</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/13121"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ife31e6798b4e728a23913179e346552a7dd338c0 </div>
<div style="display:none"> Gerrit-Change-Number: 13121 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-CC: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 05 Mar 2019 09:55:34 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: No </div>