Richard Coutts wrote:
Thanks Chris, I definately need to do this.
Does anyone have this code posted somewhere or be willing to share it with me? To say that I'm under a time constraint, would be an understatement.
As Ben wrote some days ago, the emulator with debug roms have this feature included. But I guess it looks like (it's by heart, may not compile correctly):
void *DebugMemPtrNew(UInt32 size)
{
// allocate memory block + wall
void* result = MemPtrNew(size + 2 * sizeof(UInt32));
// put a wall at the beginning and the end
((UInt32 *) result)[0] = 0xdeadbeef;
((UInt8 *) result)[size + sizeof(UInt32)] = 0xde;
((UInt8 *) result)[size + sizeof(UInt32) + 1] = 0xad;
((UInt8 *) result)[size + sizeof(UInt32) + 2] = 0xbe;
((UInt8 *) result)[size + sizeof(UInt32) + 3] = 0xef; // return the adjust pointer
return ((UInt8 *) result + sizeof(UInt32))
}void DebugMemPtrFree(void *ptr)
{
// get the correct pointer
UInt8 *tmp = ((UInt8*) ptr) - sizeof(UInt32);UInt32 size = MemPtrSize(tmp);
if (((UInt32 *) tmp)[0] != 0xdeadbeef)
Alert("You trashed the beginning!");
if ((tmp[size - sizeof(UInt32)] != 0xde) ||
(tmp[size - sizeof(UInt32) + 1] != 0xad) ||
(tmp[size - sizeof(UInt32) + 2] != 0xbe) ||
(tmp[size - sizeof(UInt32) + 3] != 0xef))
Alert("You trashed the end!"); // free the correct pointer
MemPtrFree(((UInt8*) ptr) - sizeof(UInt32));
}Regards Henk
-- ------------------------------------------------------------------------- Henk Jonas [EMAIL PROTECTED] Palm OS � certified developer
Please contact me, if you need an off-side contract worker. -------------------------------------------------------------------------
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
