add pic_vec_extend_ip (for internal API)

This commit is contained in:
Yuichi Nishiwaki 2013-11-15 19:30:25 +09:00
parent c62505b930
commit 9662ab30ec
2 changed files with 14 additions and 0 deletions

View File

@ -103,6 +103,7 @@ pic_value pic_str_new_cstr(pic_state *, const char *);
struct pic_vector *pic_vec_new(pic_state *, size_t);
struct pic_vector *pic_vec_new_from_list(pic_state *, pic_value);
void pic_vec_extend_ip(pic_state *, struct pic_vector *, int);
int pic_parse_file(pic_state *, FILE *file, pic_value *);
int pic_parse_cstr(pic_state *, const char *, pic_value *);

View File

@ -32,6 +32,19 @@ pic_vec_new_from_list(pic_state *pic, pic_value data)
return vec;
}
void
pic_vec_extend_ip(pic_state *pic, struct pic_vector *vec, int size)
{
int len, i;
len = vec->len;
vec->len = size;
vec->data = (pic_value *)pic_realloc(pic, vec->data, sizeof(pic_value) * size);
for (i = len; i < size; ++i) {
vec->data[i] = pic_false_value();
}
}
static pic_value
pic_vec_vector_p(pic_state *pic)
{