void FreeImages(void) { int i; for (i=0; i<numimages; i++) { DeallocateImage(imagelist[i]); } ResetImages(); }
void FreeMIPMap(mipmap * mip) { int i; /* don't free the original image here, FreeImages() will */ /* get it when all else is completed. */ for (i=1; i<mip->levels; i++) { DeallocateImage(mip->images[i]); } free(mip->images); free(mip); }
mipmap * LoadMIPMap(const char * filename, int maxlevels) { rawimage * img; mipmap * mip; img = AllocateImageFile(filename); if (img == NULL) return NULL; LoadRawImage(img); mip = CreateMIPMap(img, maxlevels); if (mip == NULL) { DeallocateImage(img); free(mip); return NULL; } return mip; }
ImageClass& ImageClass::operator=(const ImageClass& objToCopy) { //check to see if myImage.pixels == NULL and ; deallocate if != NULL if(myImage.pixels != NULL && objToCopy != *this) { //deallocate myImage DeallocateImage(myImage); } //copy the image myImage = CopyImage(objToCopy.myImage); //set name name = objToCopy.name + "-Assigned"; //print out constructor identification cout << "Operator: Assignment - " << name << endl; return *this; }
// Attempts to mark an entry as deleted RETURN_TYPE AE_DeleteImage( char *Key ) { unsigned index = UHashMod( Key ); unsigned indexStart = index; // Only search through clusters, don't hop over empty entries while(!IsEmpty( IMABE_TABLE, index )) { // Break from loop if found matching entry if(IMABE_TABLE[index] != DELETED) { if(strcmp(IMABE_TABLE[index]->ID, Key) == 0) { DeallocateImage( IMABE_TABLE[index]->ID ); IMABE_TABLE[index] = DELETED; isTableFull = FALSE; return RETURN_SUCCESS; } } ++index; // wraparound to beginning of table if(index == TABLESIZE) { index = 0; } // If searched entire table if(indexStart == index) { break; } } printf("ERROR: Failed to delete: %s; (entry not found).\n", Key); return RETURN_FAILURE; }
ImageClass::~ImageClass() { cout << "Deconstructor: - " << name << endl; DeallocateImage(myImage); }