Skip to content

Commit

Permalink
Fix various thinkos in CArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Dec 18, 2011
1 parent fab287d commit cde2f95
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/6model/reprs/CArray.c
Expand Up @@ -153,11 +153,12 @@ static void die_idx_nyi(PARROT_INTERP) {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"CArray representation does not fully indexed storage yet");
}
static void expand(PARROT_INTERP, CArrayBody *body, INTVAL min_size) {
static void expand(PARROT_INTERP, CArrayREPRData *repr_data, CArrayBody *body, INTVAL min_size) {
INTVAL next_size = 2 * body->allocated;
if (min_size > next_size)
next_size = min_size;
mem_sys_realloc(body->storage, next_size);
body->storage = mem_sys_realloc(body->storage, next_size * repr_data->elem_size);
body->allocated = next_size;
}
static void * at_pos_ref(PARROT_INTERP, STable *st, void *data, INTVAL index) {
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
Expand All @@ -175,10 +176,12 @@ static void bind_pos_ref(PARROT_INTERP, STable *st, void *data, INTVAL index, vo
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
CArrayBody *body = (CArrayBody *)data;
STable *type_st = STABLE(repr_data->elem_type);
if (body->allocated && index >= body->elems)
expand(interp, body, index + 1);
if (body->allocated && index >= body->allocated)
expand(interp, repr_data, body, index + 1);
/* XXX make sure this is appropriate, once we support other than int/num elems. */
type_st->REPR->copy_to(interp, type_st, value, ((char *)body->storage) + index * repr_data->elem_size);
if (index >= body->elems)
body->elems = index;
}
static void bind_pos_boxed(PARROT_INTERP, STable *st, void *data, INTVAL index, PMC *obj) {
CArrayREPRData *repr_data = (CArrayREPRData *)st->REPR_data;
Expand Down

0 comments on commit cde2f95

Please sign in to comment.