In mem_pool, check for an existing ID entry before creating a new one

This commit is contained in:
Martin Willi
2012-09-20 11:04:55 +02:00
parent a69bc12a3a
commit f0a2fef8a5
+4 -1
View File
@@ -271,6 +271,9 @@ static int get_new(private_mem_pool_t *this, identification_t *id)
uintptr_t offset = 0; uintptr_t offset = 0;
if (this->unused < this->size) if (this->unused < this->size)
{
entry = this->leases->get(this->leases, id);
if (!entry)
{ {
INIT(entry, INIT(entry,
.id = id->clone(id), .id = id->clone(id),
@@ -278,7 +281,7 @@ static int get_new(private_mem_pool_t *this, identification_t *id)
.offline = linked_list_create(), .offline = linked_list_create(),
); );
this->leases->put(this->leases, entry->id, entry); this->leases->put(this->leases, entry->id, entry);
}
/* assigning offset, starting by 1 */ /* assigning offset, starting by 1 */
offset = ++this->unused; offset = ++this->unused;
entry->online->insert_last(entry->online, (void*)offset); entry->online->insert_last(entry->online, (void*)offset);