Code:
unsigned int Size;
unsigned char * newbuffer = new unsigned char[ Size + 2 ];
Size will be whatever is stored in memory(so random untill you initialize it as something)
Also, an int is 4 bytes, so if you only want a two byte header use
Code:
unsigned short Size = reinterpret_cast<unsigned short>(sizeof(Buffer));
Now, to allocate memory you could use malloc(size)
So your code will be something along the lines of this:
Code:
char *buffer = malloc(Size+2);
buffer[0] = Size;
memcpy(buffer[2], oldBuffer, Size);
Make sure to initialize Size though(or allocate memory for the new buffer AFTER you used sizeof(oldbuffer)