Changed object_depot_store() return value to void. It is now always takes

over ownership of the object. Fixes double free introduced in r35605.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35608 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-02-24 19:04:41 +00:00
parent 27f78bf522
commit 464d9f1252
3 changed files with 6 additions and 6 deletions

View File

@ -41,7 +41,7 @@ status_t object_depot_init(object_depot* depot, size_t capacity,
void object_depot_destroy(object_depot* depot, uint32 flags);
void* object_depot_obtain(object_depot* depot);
int object_depot_store(object_depot* depot, void* object, uint32 flags);
void object_depot_store(object_depot* depot, void* object, uint32 flags);
void object_depot_make_empty(object_depot* depot, uint32 flags);

View File

@ -249,7 +249,7 @@ object_depot_obtain(object_depot* depot)
}
int
void
object_depot_store(object_depot* depot, void* object, uint32 flags)
{
DepotMagazine* freeMagazine = NULL;
@ -266,7 +266,7 @@ object_depot_store(object_depot* depot, void* object, uint32 flags)
while (true) {
if (store->loaded != NULL && store->loaded->Push(object))
return 1;
return;
if ((store->previous != NULL && store->previous->IsEmpty())
|| exchange_with_empty(depot, store->previous, freeMagazine)) {
@ -292,7 +292,7 @@ object_depot_store(object_depot* depot, void* object, uint32 flags)
DepotMagazine* magazine = alloc_magazine(depot, flags);
if (magazine == NULL) {
depot->return_object(depot, depot->cookie, object, flags);
return 0;
return;
}
readLocker.Lock();

View File

@ -696,8 +696,8 @@ object_cache_free(object_cache* cache, void* object, uint32 flags)
T(Free(cache, object));
if (!(cache->flags & CACHE_NO_DEPOT)) {
if (object_depot_store(&cache->depot, object, flags))
return;
object_depot_store(&cache->depot, object, flags);
return;
}
MutexLocker _(cache->lock);