X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/16b20e711ae0d7456d2e3349217d3e0e2ddbb594..1e8d80477a3e058a30c477955f1e0c56deb6e956:/Pooling.hpp?ds=sidebyside diff --git a/Pooling.hpp b/Pooling.hpp index c7d7ae3..1c155fe 100644 --- a/Pooling.hpp +++ b/Pooling.hpp @@ -1,5 +1,5 @@ -/* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2015 Jay Freeman (saurik) +/* Cycript - The Truly Universal Scripting Language + * Copyright (C) 2009-2016 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -115,10 +115,17 @@ class CYPool { return reinterpret_cast(data); } + template + Type_ *calloc(size_t count, size_t size, size_t alignment = CYAlignment) { + Type_ *data(malloc(count * size, alignment)); + memset(data, 0, count * size); + return data; + } + char *strdup(const char *data) { if (data == NULL) return NULL; - return reinterpret_cast(memdup(data, strlen(data) + 1, 1)); + return memdup(data, strlen(data) + 1, 1); } template @@ -228,6 +235,7 @@ struct CYData { CYData() : count_(1) { + _assert(pool_ != NULL); } CYData(CYPool &pool) :