summaryrefslogtreecommitdiff
path: root/src/newgrf_text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newgrf_text.cpp')
-rw-r--r--src/newgrf_text.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 5b3e7d03c..59edbb22e 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -125,24 +125,39 @@ public:
return new (strlen(text) + 1) GRFText(langid, text);
}
+ /**
+ * Helper allocation function to disallow something.
+ * Don't allow simple 'news'; they wouldn't have enough memory.
+ * @param size the amount of space not to allocate
+ */
+ void *operator new(size_t size)
+ {
+ NOT_REACHED();
+ }
+
+ /**
+ * Free the memory we allocated
+ * @param p memory to free
+ */
+ void operator delete(void *p)
+ {
+ free(p);
+ }
private:
GRFText(byte langid_, const char *text_) : next(NULL), langid(langid_)
{
strcpy(text, text_);
}
+ /**
+ * Allocate memory for this class.
+ * @param size the size of the instance
+ * @param extra the extra memory for the text
+ * @return the requested amount of memory for both the instance and the text
+ */
void *operator new(size_t size, size_t extra)
{
- return ::operator new(size + extra);
- }
-
-public:
- /* dummy operator delete to silence VC8:
- * 'void *GRFText::operator new(size_t,size_t)' : no matching operator delete found;
- * memory will not be freed if initialization throws an exception */
- void operator delete(void *p, size_t extra)
- {
- return ::operator delete(p);
+ return MallocT<byte>(size + extra);
}
public: