Z
Hi,..
ich habe es ein bissl umgeschrieben, der fehler tritt dennoch an exakt gleicher stelle auf (Zeile 57):
PF::__2D_vector_array::__2D_vector_array()
{
this->vArray=(PF::__2D_vector*)LocalAlloc(LPTR,sizeof(PF::__2D_vector));
this->vArray_length=(int*)LocalAlloc(LPTR,sizeof(int));
*this->vArray_length=0;
};
PF::__2D_vector_array::__2D_vector_array(const PF::__2D_vector_array &__cpy)
{
this->vArray_length=(int*)LocalAlloc(LPTR,sizeof(int));
*this->vArray_length=*__cpy.vArray_length;
if(this->vArray_length>0){
this->vArray=(PF::__2D_vector*)LocalAlloc(LPTR,sizeof(PF::__2D_vector)*(*(this->vArray_length)));
if(this->vArray!=NULL){
CopyMemory(this->vArray,__cpy.vArray,(*this->vArray_length)*sizeof(PF::__2D_vector));
//CopyMemory ist hier nicht angebracht da nur die pointer kopiert würden
}
else{*this->vArray_length=0;}
}else{this->vArray=NULL;};
};
PF::__2D_vector_array::~__2D_vector_array()
{
//standart d'toren werden bei localfree nicht aufgerufen
LocalFree(this->vArray);
this->vArray=NULL;
LocalFree(this->vArray_length);
this->vArray_length=NULL;
};
PF::__2D_vector &PF::__2D_vector_array::operator [](int i)
{
if(*this->vArray_length>i){
return *(this->vArray + sizeof(PF::__2D_vector)*i);}
PF::__2D_vector ta;
return ta;
};
void PF::__2D_vector_array::push_back(const PF::__2D_vector &__cpy)
{
HANDLE procHeap = GetProcessHeap();
HeapValidate(procHeap, 0, this->vArray);
HeapValidate(procHeap,0, this->vArray_length);
const PF::__2D_vector *checkHeap;
checkHeap=&__cpy;
HeapValidate(0,0,checkHeap);
(*this->vArray_length)++;
int laenge=(*this->vArray_length);
size_t size_of_vecs=sizeof(PF::__2D_vector)*laenge;
size_t offset_of_last_vec=sizeof(PF::__2D_vector)*(laenge-1);
PF::__2D_vector * vArrayNew=NULL;
vArrayNew=(PF::__2D_vector*)LocalAlloc(LPTR,size_of_vecs);
//this->vArray=(PF::__2D_vector*)LocalReAlloc(this->vArray,(laenge)*sizeof(PF::__2D_vector),LPTR);
CopyMemory(vArrayNew,this->vArray,offset_of_last_vec);
if(LocalFree(this->vArray)!=NULL)
{
int i=GetLastError();
i+=0;
}
this->vArray=NULL;
this->vArray=vArrayNew;
if(this->vArray!=NULL)
{
*(this->vArray+((*this->vArray_length)-1)*sizeof(PF::__2D_vector))=__cpy;
}else{
int i=GetLastError();
i+=0;
}
};
Die Klasse PF::__2D_vector hat keine private ptr's, dementsprechend brauche ich auch keinen speicher zu allozieren etc..
grüße und kopfkratzen