int main()
{
int *ptr = new int(3); // pointer to single int with value 3.
int *arr = new int[3]; // pointer to array of 3 ints with undetermined values.
delete ptr; // That which is allocated with new must be deallocated with delete.
delete [] arr; // That which is allocated with new [] must be deallocated with delete []. Note: empty [] brackets.
}
Result
|
V
+—–+—–+—–+—–+
|Magic| Len | Data… |
+—–+—–+—–+—–+
^
|
Actual Returned Data Block
int *allocate(int len) {
int *block = new int[len + 3];
block[0] = magic_number;
block[1] = len;
int *data = block+2;
return data;
}
void allocate(int *data) {
int *block = data-2;
delete [] block;
}
I am using Dawn of Time codebase, and since moving to an online server (genesismuds) we have been noticing that the game seems to be dumping a TON of junk into object extra desc fields when writing playerfiles…
I am at my limit on patience with this, and since it affects playerfiles AND areafiles it is highly aggitating to my builders as well. Anyone willing to help us fix it??
Some additional info: do not see this problem happening when running on desktop at home. only with instances of it on host server. home comp is windows, host of course is linux