From 5f679d1cd3eae30470744608fd91d8943dd2ad8b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 21 Jan 2010 22:16:03 +0000 Subject: [PATCH] Resize(): Added boolean "force" parameter that allows to force setting the new memory, even if it isn't needed at that time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35231 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/util/OpenHashTable.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/headers/private/kernel/util/OpenHashTable.h b/headers/private/kernel/util/OpenHashTable.h index 3556dc262a..503cfef12a 100644 --- a/headers/private/kernel/util/OpenHashTable.h +++ b/headers/private/kernel/util/OpenHashTable.h @@ -255,12 +255,14 @@ public: /*! Resizes the table using the given allocation. The allocation must not be \c NULL. It must be of size \a size, which must a value returned earlier by ResizeNeeded(). If the size requirements have changed in the - meantime, the method free()s the given allocation and returns \c false. + meantime, the method free()s the given allocation and returns \c false, + unless \a force is \c true, in which case the supplied allocation is + used in any event. Otherwise \c true is returned. */ - bool Resize(void* allocation, size_t size) + bool Resize(void* allocation, size_t size, bool force = false) { - if (size != ResizeNeeded()) { + if (!force && size != ResizeNeeded()) { free(allocation); return false; }