Moving objects around

Started by
0 comments, last by SiCrane 12 years, 3 months ago
Hello

I am loading files into memory and have a pointer in a strcut point to it


struct RawFile
{
// pointer to buffer and size of buffer
unsigned int DataSize;
char* pData;
};


This object will get placed in a vector called UnprocessedFiles.

std::vector<RawFile> UnprocessedFiles;


Now, once in a while I want to run through the vector and process the content of each file and place that content in to another vector. Instead of making a new copy of the file in memory I wish only to add more members to the RawFile struct:

struct RawFile
{
// pointer to buffer and size of buffer
unsigned int DataSize;
char* pData;
bool IsProcessed;
MeshContainer* pMesh;
TextureContainer* pTextures;
};


Now comes my question, I wish to copy elements from one vector to another called ProcessedFiles.

//for loop
ProcessedFiles.push_back(UnprocessedFiles);


Now will this create a duplicate RawFile instance or will the same adress be copied?

Would the solution then to make a pointer to a RawFile and push_back that ?
Advertisement
Are you asking if the two pData pointers will be the same? Then, yes, they will be the same.
No, i'm asking if &UnprocessedFiles == &ProcessedFiles

This topic is closed to new replies.

Advertisement