Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[strings] first of many patches from darbelo++ getting rid of ->strst…

…art abuse

git-svn-id: https://svn.parrot.org/parrot/trunk@40939 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit bbd8ef43508aa2c4a06a48ee452f2901ec67182b 1 parent 4591dbb
@cotto cotto authored
View
11 src/dynpmc/gdbmhash.pmc
@@ -214,13 +214,16 @@ Returns true if the hash size is not zero.
if (!dbf) return;
keystr = make_hash_key(interp, key);
- key_gdbm.dsize = keystr->strlen;
- key_gdbm.dptr = keystr->strstart;
- val_gdbm.dsize = value->strlen;
- val_gdbm.dptr = value->strstart;
+ key_gdbm.dptr = Parrot_str_to_cstring(interp, keystr);
+ key_gdbm.dsize = strlen(key_gdbm.dptr);
+ val_gdbm.dptr = Parrot_str_to_cstring(interp, value);
+ val_gdbm.dsize = strlen(val_gdbm.dptr);
gdbm_store(dbf, key_gdbm, val_gdbm, GDBM_REPLACE);
+ Parrot_str_free_cstring(key_gdbm.dptr);
+ Parrot_str_free_cstring(val_gdbm.dptr);
+
return;
}
View
11 src/misc.c
@@ -112,6 +112,8 @@ Parrot_vsnprintf(PARROT_INTERP, ARGOUT(char *targ),
size_t len, ARGIN(const char *pat), va_list args)
{
ASSERT_ARGS(Parrot_vsnprintf)
+ char *str_ret;
+ size_t str_len;
if (len == 0)
return;
len--;
@@ -119,12 +121,15 @@ Parrot_vsnprintf(PARROT_INTERP, ARGOUT(char *targ),
const STRING * const ret = Parrot_vsprintf_c(interp, pat, args);
/* string_transcode(interp, ret, NULL, NULL, &ret); */
- if (len > ret->bufused) {
- len = ret->bufused;
+ str_ret = Parrot_str_to_cstring(interp, ret);
+ str_len = strlen(str_ret);
+ if (len > str_len) {
+ len = str_len;
}
if (len)
- memcpy(targ, ret->strstart, len);
+ memcpy(targ, str_ret, len);
+ Parrot_str_free_cstring(str_ret);
}
targ[len] = 0;
}
View
10 src/pmc/fixedbooleanarray.pmc
@@ -550,15 +550,15 @@ Used to unarchive the string.
if (info->extra_flags == EXTRA_IS_NULL) {
unsigned char * bit_array;
+ UINTVAL threshold;
const INTVAL size = VTABLE_shift_integer(INTERP, io);
STRING * const s = VTABLE_shift_string(INTERP, io);
- bit_array = (unsigned char*)mem_sys_allocate_zeroed(s->bufused);
- mem_sys_memcopy(bit_array, s->strstart, s->bufused);
-
+ bit_array = Parrot_str_to_cstring(INTERP, s);
+ threshold = Parrot_str_byte_length(interp, s) * BITS_PER_CHAR;
+
SET_ATTR_size(INTERP, SELF, size);
- SET_ATTR_resize_threshold(INTERP, SELF,
- s->bufused * BITS_PER_CHAR);
+ SET_ATTR_resize_threshold(INTERP, SELF, threshold);
SET_ATTR_bit_array(INTERP, SELF, bit_array);
}
}
View
5 src/pmc/nci.pmc
@@ -302,6 +302,7 @@ class, the PMC arguments are shifted down.
VTABLE opcode_t *invoke(void *next) {
Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
nci_sub_t func;
+ char *sig_str;
void *orig_func;
PMC *cont;
@@ -324,7 +325,9 @@ class, the PMC arguments are shifted down.
nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
/* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
- jit_func(INTERP, SELF, (char *) nci_info->pcc_params_signature->strstart);
+ sig_str = Parrot_str_to_cstring(interp, nci_info->pcc_params_signature);
+ jit_func(INTERP, SELF, sig_str);
+ Parrot_str_free_cstring(sig_str);
}
else {
if (PObj_flag_TEST(private2, SELF)) {
View
3  src/pmc/resizablebooleanarray.pmc
@@ -453,8 +453,7 @@ Used to unarchive the string.
const UINTVAL tail_pos = VTABLE_shift_integer(INTERP, io);
STRING * const s = VTABLE_shift_string(INTERP, io);
- bit_array = (unsigned char *)mem_sys_allocate_zeroed(s->bufused);
- mem_sys_memcopy(bit_array, (unsigned char *)s->strstart, s->bufused);
+ bit_array = Parrot_str_to_cstring(INTERP, s);
PMC_data(SELF) =
mem_allocate_zeroed_typed(Parrot_ResizableBooleanArray_attributes);
Please sign in to comment.
Something went wrong with that request. Please try again.