[#4766] Wiki — "Glen Stampoultzis" <trinexus@...>

21 messages 2000/09/04
[#4768] RE: Wiki — "NAKAMURA, Hiroshi" <nahi@...> 2000/09/04

Hi, Glen,

[#4783] Re: Wiki — Masatoshi SEKI <m_seki@...> 2000/09/04

[#4785] Re: Wiki — "NAKAMURA, Hiroshi" <nakahiro@...> 2000/09/05

Howdy,

[#4883] Re-binding a block — Dave Thomas <Dave@...>

16 messages 2000/09/12

[#4930] Perl 6 rumblings -- RFC 225 (v1) Data: Superpositions — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/09/15

[#4936] Ruby Book Eng. translation editor's questions — Jon Babcock <jon@...>

20 messages 2000/09/16

[#5045] Proposal: Add constants to Math — Robert Feldt <feldt@...>

15 messages 2000/09/21

[#5077] Crazy idea? infix method calls — hal9000@...

This is a generalization of the "in" operator idea which I

17 messages 2000/09/22

[#5157] Compile Problem with 1.6.1 — Scott Billings <aerogems@...>

When I try to compile Ruby 1.6.1, I get the following error:

15 messages 2000/09/27

[ruby-talk:5208] killing ALLOCA_N

From: "Brian F. Feldman" <green@...>
Date: 2000-09-30 18:16:14 UTC
List: ruby-talk #5208
ALLOCA_N() isn't good because stacks are not meant to be huge and often have 
reasonable resource limits imposed on them to prevent programs from running 
away in infinite loops until they use all the machine's memory.  alloca() 
would be an elegant solution to the necessity of temporary storage -- so 
maybe ALLOCA_N() should just allocate a new "InternalData" object or 
something and return its data pointer?

Ruby should be using its internal GC for all memory allocations, I believe.  
Here's an example of something using ALLOCA_N that was easily corrected to 
use the proper Ruby type instead (and it's more readable).  I'd like to see 
this kind of change made for another reason, too: it makes Ruby more 
suitable for an embedded interpreter in small devices.

--- re.c	Fri Sep  1 05:18:11 2000
+++ /home/green/ruby/re.c	Mon Sep 25 13:42:47 2000
@@ -1035,7 +1035,7 @@
     int argc;
     VALUE *argv;
 {
-    VALUE str, kcode;
+    VALUE str, kcode, newstr;
     int kcode_saved = reg_kcode;
     char *s, *send, *t;
     char *tmp;
@@ -1049,7 +1049,8 @@
     }
     s = rb_str2cstr(str, &len);
     send = s + len;
-    tmp = ALLOCA_N(char, len*2);
+    newstr = rb_str_new(0, len * 2);
+    tmp = RSTRING(newstr)->ptr;
     t = tmp;
 
     for (; s < send; s++) {
@@ -1072,9 +1073,10 @@
 	}
 	*t++ = *s;
     }
+    rb_str_resize(newstr, t - tmp);
     kcode_reset_option();
 
-    return rb_str_new(tmp, t - tmp);
+    return newstr;
 }
 
 int


--
 Brian Fundakowski Feldman           \  FreeBSD: The Power to Serve!  /
 green@FreeBSD.org                    `------------------------------'



In This Thread

Prev Next