[svn:parrot] r40983 - in trunk/src: . jit/i386 pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Sat Sep 5 01:05:08 UTC 2009
Author: cotto
Date: Sat Sep 5 01:05:05 2009
New Revision: 40983
URL: https://trac.parrot.org/parrot/changeset/40983
Log:
[string] eliminate some ->strstart abuse, courtesy of darbelo++
Modified:
trunk/src/hash.c
trunk/src/jit/i386/jit_defs.c
trunk/src/pmc/string.pmc
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c Sat Sep 5 00:14:38 2009 (r40982)
+++ trunk/src/hash.c Sat Sep 5 01:05:05 2009 (r40983)
@@ -206,7 +206,7 @@
return 1;
/* COWed strings */
- if (s1->strstart == s2->strstart && s1->bufused == s2->bufused)
+ if (Buffer_bufstart(s1) == Buffer_bufstart(s2) && s1->bufused == s2->bufused)
return 0;
return CHARSET_COMPARE(interp, s1, s2);
Modified: trunk/src/jit/i386/jit_defs.c
==============================================================================
--- trunk/src/jit/i386/jit_defs.c Sat Sep 5 00:14:38 2009 (r40982)
+++ trunk/src/jit/i386/jit_defs.c Sat Sep 5 01:05:05 2009 (r40983)
@@ -2084,8 +2084,9 @@
const int ST_SIZE_OF = 124;
const int JIT_ALLOC_SIZE = 1024;
+ char *signature_str = Parrot_str_to_cstring(interp, signature);
/* skip over the result */
- char *sig = (char *)signature->strstart + 1;
+ char *sig = signature_str + 1;
size_t stack_space_needed = calc_signature_needs(sig,
&string_buffer_count);
@@ -2240,6 +2241,7 @@
case '4':
case 'V':
mem_free_executable(jit_info.native_ptr, JIT_ALLOC_SIZE);
+ Parrot_str_free_cstring(signature_str);
return NULL;
break;
default:
@@ -2250,6 +2252,7 @@
* cleanup and try nci.c
*/
mem_free_executable(jit_info.native_ptr, JIT_ALLOC_SIZE);
+ Parrot_str_free_cstring(signature_str);
return NULL;
}
args_offset +=4;
@@ -2294,7 +2297,7 @@
/* now place return value in registers */
/* first in signature is the return value */
- sig = (char *)signature->strstart; /* the result */
+ sig = signature_str; /* the result */
switch (*sig) {
/* I have no idea how to handle these */
case '2':
@@ -2393,6 +2396,7 @@
* oops unknown signature:
* cleanup and try nci.c
*/
+ Parrot_str_free_cstring(signature_str);
mem_free_executable(jit_info.native_ptr, JIT_ALLOC_SIZE);
return NULL;
}
@@ -2413,6 +2417,7 @@
PObj_custom_destroy_SET(pmc_nci);
if (sizeptr)
*sizeptr = JIT_ALLOC_SIZE;
+ Parrot_str_free_cstring(signature_str);
return (void *)D2FPTR(jit_info.arena.start);
}
Modified: trunk/src/pmc/string.pmc
==============================================================================
--- trunk/src/pmc/string.pmc Sat Sep 5 00:14:38 2009 (r40982)
+++ trunk/src/pmc/string.pmc Sat Sep 5 01:05:05 2009 (r40983)
@@ -906,7 +906,7 @@
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_ENCODING,
"Can't translate non-ascii");
- p = (unsigned char *)src->strstart;
+ p = (unsigned char *)Buffer_bufstart(src);
/* TODO verify trans table */
GETATTR_FixedIntegerArray_int_array(INTERP, table, tr_data);
@@ -940,7 +940,7 @@
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_ENCODING,
"Can't reverse non-ascii");
- p = (unsigned char *)src->strstart;
+ p = (unsigned char *)Buffer_bufstart(src);
for (i = 0, --len; i < len; ++i, --len) {
const unsigned char ch = p[len];
@@ -973,7 +973,7 @@
"Can't is_integer non-ascii");
i = 0;
- p = (unsigned char *)src->strstart;
+ p = (unsigned char *)Buffer_bufstart(src);
if (p[i] == '-' || p[i] == '+' ||
(p[i] >= '0' && p[i] <= '9')) {
More information about the parrot-commits
mailing list