clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
						download: 
* [PATCH 3/6] use RB_GC_GUARD instead of volatile
      [irrelevant] <1392505748-13740-1-git-send-email-normalperson@yhbt.net>
@ 2014-02-15 23:09 ` 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	[relevance 7%]

Results 1-1 of 1 | reverse results
    [irrelevant] <1392505748-13740-1-git-send-email-normalperson@yhbt.net>
2014-02-15 23:09 ` [PATCH 3/6] use RB_GC_GUARD instead of volatile Eric Wong


clogger RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/clogger-public
	git clone --mirror http://ou63pmih66umazou.onion/clogger-public

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.clogger
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.clogger

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox