diff options
Diffstat (limited to 'sca-cpp')
-rw-r--r-- | sca-cpp/trunk/kernel/gc.hpp | 56 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/json/json.hpp | 2 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/server/client-test.hpp | 7 |
3 files changed, 34 insertions, 31 deletions
diff --git a/sca-cpp/trunk/kernel/gc.hpp b/sca-cpp/trunk/kernel/gc.hpp index 4b29d66d64..ca01fdf95f 100644 --- a/sca-cpp/trunk/kernel/gc.hpp +++ b/sca-cpp/trunk/kernel/gc.hpp @@ -87,19 +87,19 @@ public: */ class gc_pool { public: - gc_pool() : p(NULL) { + gc_pool() : apr_pool(NULL) { } - gc_pool(apr_pool_t* p) : p(p) { + gc_pool(apr_pool_t* p) : apr_pool(p) { } - gc_pool(const gc_pool& pool) : p(pool.p) { + gc_pool(const gc_pool& pool) : apr_pool(pool.apr_pool) { } gc_pool& operator=(const gc_pool& pool) { if (this == &pool) return *this; - p = pool.p; + apr_pool = pool.apr_pool; return *this; } @@ -108,14 +108,14 @@ private: friend class gc_global_pool_t; friend class gc_scoped_pool; - apr_pool_t* p; + apr_pool_t* apr_pool; }; /** * Return APR pool used by a gc_pool. */ apr_pool_t* pool(const gc_pool& pool) { - return pool.p; + return pool.apr_pool; } /** @@ -148,14 +148,15 @@ apr_pool_t* gc_pool_stack = NULL; * Return the current memory pool. */ apr_pool_t* gc_current_pool() { - apr_pool_t* p = gc_pool_stack; - if (p != NULL) - return p; + apr_pool_t* apr_pool = gc_pool_stack; + if (apr_pool != NULL) + return apr_pool; // Create a parent pool for the current thread - apr_pool_create(&p, NULL); - gc_pool_stack = p; - return p; + apr_pool_create(&apr_pool, NULL); + assert(apr_pool != NULL); + gc_pool_stack = apr_pool; + return apr_pool; } /** @@ -184,22 +185,23 @@ class gc_scoped_pool : public gc_pool { public: gc_scoped_pool() : gc_pool(NULL), prev(gc_current_pool()), owner(true) { - apr_pool_create(&p, NULL); - gc_push_pool(p); + apr_pool_create(&apr_pool, NULL); + assert(apr_pool != NULL); + gc_push_pool(apr_pool); } gc_scoped_pool(apr_pool_t* pool) : gc_pool(pool), prev(gc_current_pool()), owner(false) { - gc_push_pool(p); + gc_push_pool(apr_pool); } ~gc_scoped_pool() { if (owner) - apr_pool_destroy(p); + apr_pool_destroy(apr_pool); gc_pop_pool(prev); } private: - gc_scoped_pool(const unused gc_scoped_pool& pool) : gc_pool(pool.p), prev(NULL), owner(false) { + gc_scoped_pool(const unused gc_scoped_pool& pool) : gc_pool(pool.apr_pool), prev(NULL), owner(false) { } apr_pool_t* prev; @@ -217,9 +219,10 @@ template<typename T> apr_status_t gc_pool_cleanup(void* v) { } template<typename T> T* gc_new(apr_pool_t* p) { - void* m = apr_palloc(p, sizeof(T)); - apr_pool_cleanup_register(p, m, gc_pool_cleanup<T>, apr_pool_cleanup_null) ; - return static_cast<T*>(m); + void* gc_new_ptr = apr_palloc(p, sizeof(T)); + assert(gc_new_ptr != NULL); + apr_pool_cleanup_register(p, gc_new_ptr, gc_pool_cleanup<T>, apr_pool_cleanup_null) ; + return static_cast<T*>(gc_new_ptr); } template<typename T> T* gc_new(const gc_pool& p) { @@ -240,10 +243,11 @@ template<typename T> apr_status_t gc_pool_acleanup(void* v) { } template<typename T> T* gc_anew(apr_pool_t* p, int n) { - int* m = static_cast<int*>(apr_palloc(p, sizeof(int) + sizeof(T[n]))); - *m = n; - apr_pool_cleanup_register(p, m, gc_pool_acleanup<T>, apr_pool_cleanup_null) ; - return (T*)(m + 1); + int* gc_anew_ptr = static_cast<int*>(apr_palloc(p, sizeof(int) + sizeof(T[n]))); + assert(gc_anew_ptr != NULL); + *gc_anew_ptr = n; + apr_pool_cleanup_register(p, gc_anew_ptr, gc_pool_acleanup<T>, apr_pool_cleanup_null) ; + return (T*)(gc_anew_ptr + 1); } template<typename T> T* gc_anew(const gc_pool& p, int n) { @@ -258,7 +262,9 @@ template<typename T> T* gc_anew(int n) { * Allocate an array of chars. */ char* gc_cnew(apr_pool_t* p, int n) { - return static_cast<char*>(apr_palloc(p, n)); + char* gc_cnew_ptr = static_cast<char*>(apr_palloc(p, n)); + assert(gc_cnew_ptr != NULL); + return gc_cnew_ptr; } char* gc_cnew(int n) { diff --git a/sca-cpp/trunk/modules/json/json.hpp b/sca-cpp/trunk/modules/json/json.hpp index fc5e512d5e..1116511455 100644 --- a/sca-cpp/trunk/modules/json/json.hpp +++ b/sca-cpp/trunk/modules/json/json.hpp @@ -370,7 +370,7 @@ const failable<list<string> > writeJSON(const list<value>& l, const JSONContext& * Convert a function + params to a JSON request. */ const failable<list<string> > jsonRequest(const value& id, const value& func, const value& params, json::JSONContext& cx) { - const list<value> r = mklist<value>(mklist<value>("id", id), mklist<value>("method", func), mklist<value>("params", params)); + const list<value> r = mklist<value>(mklist<value>("id", id), mklist<value>("method", string(func)), mklist<value>("params", params)); return writeJSON(valuesToElements(r), cx); } diff --git a/sca-cpp/trunk/modules/server/client-test.hpp b/sca-cpp/trunk/modules/server/client-test.hpp index d1c8d9ba15..0f8b64a031 100644 --- a/sca-cpp/trunk/modules/server/client-test.hpp +++ b/sca-cpp/trunk/modules/server/client-test.hpp @@ -101,8 +101,8 @@ struct evalLoop { } }; -const value blob(string(3000, 'A')); -const list<value> blobs = mklist(blob, blob, blob, blob, blob); +const value blob(string(2048, 'A')); +const list<value> blobs = mklist(blob, blob); struct blobEvalLoop { const string uri; @@ -181,9 +181,6 @@ const bool testPostPerf() { + (list<value>() + "name" + string("Apple")) + (list<value>() + "blob1" + blob) + (list<value>() + "blob2" + blob) - + (list<value>() + "blob3" + blob) - + (list<value>() + "blob4" + blob) - + (list<value>() + "blob5" + blob) + (list<value>() + "price" + string("$2.99")); const list<value> val = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), i); const lambda<bool()> pl = postBlobLoop(testURI, val, ch); |