Details
-
Bug
-
Resolution: Won't Fix
-
Minor
-
None
-
3.1.0
-
Security Level: Public
-
None
-
Untriaged
-
Unknown
Description
Current code allocates but never uses cq_item[0].
Here
https://github.com/couchbase/moxi/blob/master/src/thread.c#L146
currently...
for (i = 2; i < ITEMS_PER_ALLOC; i++) |
...
|
cqi_freelist = &cq_item[1];
|
...I feel it should be
for (i = 1; i < ITEMS_PER_ALLOC; i++) |
cqi_freelist = &cq_item[0];
|
/* Allocate a bunch of items at once to reduce fragmentation */ |
cq_item = malloc(sizeof(CQ_ITEM) * ITEMS_PER_ALLOC); |
if (NULL == cq_item) |
return NULL; |
|
/* |
* Link together all the new items except the first one
|
* (which we'll return to the caller) for placement on
|
* the freelist.
|
*/
|
for (i = 2; i < ITEMS_PER_ALLOC; i++) |
cq_item[i - 1].next = &cq_item[i];
|
|
|
cb_mutex_enter(&cqi_freelist_lock);
|
cq_item[ITEMS_PER_ALLOC - 1].next = cqi_freelist;
|
cqi_freelist = &cq_item[1];
|
No harm done. Just 1/64 memory is not used effectively here.