home *** CD-ROM | disk | FTP | other *** search
- #include "AddBlock.h"
- #include "Shell.Extra.h"
- #include "Shell.Printf.h"
- #include "Update.h"
-
- #include "ChHeapSize.h"
- #include "Shell.SafeAlloc.h"
-
- #define BLOCK_INCREMENT 16
-
-
-
- void AddBlock( app_block *app, int pos, int size, int ref)
- {
- block_info *block;
- int i, j;
-
- if (size<0) {
- Shell_TextRectPrintf( app->textrect, "Negative block size at %x, (size=%i)\n", pos, size);
- return;
- }
-
- if ( app->num_blocks == app->num_blocksalloced) {
- app->num_blocksalloced += BLOCK_INCREMENT;
- app->blocks = Shell_SafeRealloc(
- app->blocks, app->num_blocksalloced*sizeof( block_info)
- );
- }
-
- /* Find where to place the block */
-
-
- for ( i=0; i<app->num_blocks; i++) {
- if ( app->blocks[i].pos > pos) break;
- }
-
- /* copy blocks up... */
- for ( j=app->num_blocks; j>i; j--) app->blocks[j] = app->blocks[j-1];
-
- block = &app->blocks[ i];
-
- block->pos = pos;
- block->size = size;
- block->ref = ref;
-
- app->num_blocks++;
- app->stats.total += size;
-
- if ( app->num_blocks==1) {
- app->min_mem = pos;
- app->max_mem = pos+size;
- }
-
- /*
- Shell_Printf( "Blocks are:\n");
- for ( i=0; i<app->num_blocks; i++) {
- Shell_Printf( "%i) %x\n", i, app->blocks[i].pos);
- }
- Shell_Printf( "\n");
- */
-
- /*Shell_Printf( "%x\n", pos);*/
-
- CheckHeapSize( app, pos, pos+size);
-
- /*Shell_ForceRectUpdateSlow( app->heaprect);*/
- ForceRegionUpdate( app, pos, size);
-
- /* Should only update the new bit of the heap... */
- /*
- {
- wimp_rect rect;
- rect.min.x = app->heapdisplay->rect.min.x;
- rect.max.x = app->heapdisplay->rect.max.x;
- rect.min.y = app->heapdisplay->rect.min.y + pos/app->words_per_os;
- rect.max.y = app->heapdisplay->rect.min.y + (pos+size)/app->words_per_os;
- }
- */
-
- }
-