const char *famText = pfSelectFileModeCreate( TOS );\r
pfCopyMemory( gScratch, (char *) Temp, (uint32) Scratch );\r
gScratch[Scratch] = '\0';\r
- PRT(("Create file = %s with famTxt %s\n", gScratch, famText ));\r
+ DBUG(("Create file = %s with famTxt %s\n", gScratch, famText ));\r
FileID = sdOpenFile( gScratch, famText );\r
TOS = ( FileID == NULL ) ? -1 : 0 ;\r
M_PUSH( (cell) FileID );\r
/* Resize memory allocated by ALLOCATE. */\r
case ID_RESIZE: /* ( addr1 u -- addr2 result ) */\r
{\r
- cell *FreePtr;\r
- \r
- FreePtr = (cell *) ( M_POP - sizeof(cell) );\r
+ cell *Addr1 = (cell *) M_POP;\r
+ // Point to validator below users address.\r
+ cell *FreePtr = Addr1 - 1;\r
if( ((uint32)*FreePtr) != ((uint32)FreePtr ^ PF_MEMORY_VALIDATOR))\r
{\r
- M_PUSH( 0 );\r
+ // 090218 - Fixed bug, was returning zero.\r
+ M_PUSH( Addr1 );\r
TOS = -3;\r
}\r
else\r
/* Copy memory including validation. */\r
pfCopyMemory( (char *) CellPtr, (char *) FreePtr, TOS + sizeof(cell) );\r
*CellPtr = (cell)(((uint32)CellPtr) ^ (uint32)PF_MEMORY_VALIDATOR);\r
- CellPtr++;\r
- M_PUSH( (cell) ++CellPtr );\r
- TOS = 0;\r
+ // 090218 - Fixed bug that was incrementing the address twice. Thanks Reinhold Straub.\r
+ // Increment past validator to user address.\r
+ M_PUSH( (cell) (CellPtr + 1) );\r
+ TOS = 0; // Result code.\r
+ // Mark old cell as dead so we can't free it twice.\r
FreePtr[0] = 0xDeadBeef;\r
pfFreeMem((char *) FreePtr);\r
}\r
else\r
{\r
- M_PUSH( 0 );\r
+ // 090218 - Fixed bug, was returning zero.\r
+ M_PUSH( Addr1 );\r
TOS = -4; /* FIXME Fix error code. */\r
}\r
}\r