summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 61500fb7a..9a82f192b 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -268,3 +268,18 @@ std::string Inventory::getName() const
}
}
}
+
+void Inventory::resize(const unsigned int newSize)
+{
+ clear();
+ if (mSize == newSize)
+ return;
+
+ for (unsigned i = 0; i < mSize; i++)
+ delete mItems[i];
+ delete [] mItems;
+
+ mSize = newSize;
+ mItems = new Item*[mSize];
+ std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
+}