home *** CD-ROM | disk | FTP | other *** search
- #include "Shell.Extra.h"
- #include "Shell.TextRect.h"
-
- #include "Structs.h"
- #include "MoveBlock.h"
- #include "ChHeapSize.h"
-
-
-
- void MoveBlock( app_block *app, int oldpos, int newpos, int newsize)
- {
- int i;
-
- /* Find old block */
- for ( i=0; i<app->num_blocks; i++) {
- if ( app->blocks[i].pos == oldpos) break;
- }
-
- /* i is the old postion of the block */
-
- if ( i<app->num_blocks) {
-
- int direction = ( newpos > oldpos ) ? 1 : -1;
- int j, k;
- block_info tempblock;
-
- app->stats.total += newsize - app->blocks[i].size;
-
- tempblock = app->blocks[i];
- tempblock.pos = newpos;
- tempblock.size = newsize;
-
- for ( j=i; j>=0 && j<app->num_blocks; j+=direction) {
- if ( (app->blocks[j].pos - newpos)*direction > 0) break;
- }
- j-=direction;
- /* j is now the new postion for the block */
-
- /* Copy the blocks between old and new postion down/up one step... */
- for ( k=i; k!=j; k+=direction)
- app->blocks[k] = app->blocks[k+direction];
-
- /* And fill in new block */
- app->blocks[j] = tempblock;
-
-
- if ( j==0 || j==app->num_blocks-1) CheckHeapSize( app, newpos, newpos+newsize);
-
- Shell_ForceRectUpdateSlow( app->heaprect);
- }
-
- else Shell_TextRectPrintf( app->textrect,
- "Couldn't find block at 0x%x, (want to realloc to 0x%x, size %i)\n",
- oldpos, newpos, newsize
- );
-
- return;
- }
-
-
-
-