From fb7f6739c5bc041a28ae45fea80f840459523f8e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 31 Jul 2009 23:46:21 -0700 Subject: unicorn_http: small cleanups and size reduction Use Data_Make_Struct instead of Data_Wrap_Struct to avoid extra steps/code in object allocation. The GC will also free() implicitly if no free callback is passed to Data_Make_Struct, and we don't need an extra method here... Since we're more comfortable with object management nowadays, just make the data_get() fail with an assertion failure if it somehow (very unlikely) ends up getting a NULL parser object. Unicorn itself has no way of recovering other than throwing errors to clients anyways and we have bigger problems if there's a GC bug causing this. Then, finally, reduce the size of our http_parser struct even more (we'll add an int back later) since we know it's safe to do so... --- ext/unicorn_http/ext_help.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ext/unicorn_http/ext_help.h') diff --git a/ext/unicorn_http/ext_help.h b/ext/unicorn_http/ext_help.h index 17f7b01..8220600 100644 --- a/ext/unicorn_http/ext_help.h +++ b/ext/unicorn_http/ext_help.h @@ -3,10 +3,11 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#ifdef DEBUG -#define TRACE() fprintf(stderr, "> %s:%d:%s\n", __FILE__, __LINE__, __FUNCTION__) -#else -#define TRACE() +#ifndef RSTRING_PTR +#define RSTRING_PTR(s) (RSTRING(s)->ptr) +#endif +#ifndef RSTRING_LEN +#define RSTRING_LEN(s) (RSTRING(s)->len) #endif #endif -- cgit v1.2.3-24-ge0c7