clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: clogger@librelist.org
Subject: [PATCH 3/6] use RB_GC_GUARD instead of volatile
Date: Sat, 15 Feb 2014 23:09:05 +0000	[thread overview]
Message-ID: <1392505748-13740-3-git-send-email-normalperson@yhbt.net> (raw)
In-Reply-To: 1392505748-13740-1-git-send-email-normalperson@yhbt.net

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



  parent reply	other threads:[~2014-02-15 23:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-15 23:09 [PATCH 1/6] blocking_helpers: remove fstat wrapper Eric Wong
2014-02-15 23:09 ` [PATCH 2/6] remove unused RARRAY_PTR macro Eric Wong
2014-02-15 23:09 ` Eric Wong [this message]
2014-02-15 23:09 ` [PATCH 4/6] prevent potential premature GC in byte_xs Eric Wong
2014-02-15 23:09 ` [PATCH 5/6] remove each_id, it was never used Eric Wong
2014-02-15 23:09 ` [PATCH 6/6] use rb_thread_call_without_gvl for Ruby 2+ Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/clogger/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392505748-13740-3-git-send-email-normalperson@yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=clogger@librelist.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).