bool *flattenBVecList(int t, int vecDim, BoolVecList* pboolVecList) { int szvec = 0; bool *array = NULL; // walk through the vector list and check few things then send the packed version bool *p = NULL; for(int i=0; i<(int)pboolVecList->size(); i++) { if(szvec == 0) { szvec = (int)((*pboolVecList)[i]->size()); p = array = new bool[szvec * pboolVecList->size()]; // we assume all vectors are the same size } else if(szvec != (*pboolVecList)[i]->size()) { yyerror("Vector list has inconsistent vectors\n"); continue; } BoolList* pfl = (*pboolVecList)[i]; for(int j=0; j<(int)pfl->size(); j++) *p++ = (*pfl)[j]; delete pfl; } if(vecDim < 0) vecDim = (int)pboolVecList->size(); // we do the test here in any case : the previous loop needed to do some "delete" anyways if((szvec != vecDim) || (t != pboolVecList->size())) { yyerror("Vector dimension in value assignment don't match the type\n"); delete array; return NULL; } return array; }