- int i;
- struct VecRec* v = PTR(vec).vec->rec;
- struct VecRec* nv = naAlloc(sizeof(struct VecRec) + sizeof(naRef) * sz);
- nv->size = sz;
- nv->alloced = sz;
- for(i=0; i<sz; i++)
- nv->array[i] = (v && i < v->size) ? v->array[i] : naNil();
- naGC_swapfree((void**)&(PTR(vec).vec->rec), nv);
+ if (sz < 0)
+ naRuntimeError(c, "size cannot be negative");
+ else
+ {
+ int i;
+ struct VecRec* v = PTR(vec).vec->rec;
+ struct VecRec* nv = naAlloc(sizeof(struct VecRec) + sizeof(naRef) * sz);
+ nv->size = sz;
+ nv->alloced = sz;
+ for(i=0; i<sz; i++)
+ nv->array[i] = (v && i < v->size) ? v->array[i] : naNil();
+ naGC_swapfree((void*)&(PTR(vec).vec->rec), nv);
+ }