clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/6] use RB_GC_GUARD instead of volatile
  @ 2014-02-15 23:09  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2014-02-15 23:09 UTC (permalink / raw)
  To: clogger

RB_GC_GUARD is more explicit in intent.
---
 ext/clogger_ext/clogger.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index 8995932..ed01534 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -170,7 +170,7 @@ static VALUE byte_xs_str(VALUE from)
 {
 	static const char esc[] = "0123456789ABCDEF";
 	unsigned char *new_ptr;
-	unsigned char *ptr = (unsigned char *)RSTRING_PTR(from);
+	const unsigned char *ptr = (const unsigned char *)RSTRING_PTR(from);
 	long len = RSTRING_LEN(from);
 	long new_len = len;
 	VALUE rv;
@@ -188,7 +188,7 @@ static VALUE byte_xs_str(VALUE from)
 
 	rv = rb_str_new(NULL, new_len);
 	new_ptr = (unsigned char *)RSTRING_PTR(rv);
-	ptr = (unsigned char *)RSTRING_PTR(from);
+	ptr = (const unsigned char *)RSTRING_PTR(from);
 	for (; --len >= 0; ptr++) {
 		unsigned c = *ptr;
 
@@ -867,7 +867,7 @@ static VALUE ccall(struct clogger *c, VALUE env)
 			rb_ary_store(rv, 1, c->headers);
 		}
 	} else {
-		volatile VALUE tmp = rb_inspect(rv);
+		VALUE tmp = rb_inspect(rv);
 
 		c->status = INT2FIX(500);
 		c->headers = c->body = rb_ary_new();
@@ -875,6 +875,7 @@ static VALUE ccall(struct clogger *c, VALUE env)
 		rb_raise(rb_eTypeError,
 		         "app response not a 3 element Array: %s",
 			 RSTRING_PTR(tmp));
+		RB_GC_GUARD(tmp);
 	}
 
 	return rv;
-- 
1.9.0.rc3.13.gda73b5f



^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2014-02-15 23:09     [PATCH 1/6] blocking_helpers: remove fstat wrapper Eric Wong
2014-02-15 23:09  7% ` [PATCH 3/6] use RB_GC_GUARD instead of volatile Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/clogger.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).