Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/mm/common.c

    r5a6cc679 ra35b458  
    7272{
    7373        link_t *link;
    74        
     74
    7575        while ((link = list_first(&mem_blocks)) != NULL) {
    7676                mem_block_t *block = list_get_instance(link, mem_block_t, link);
    7777                free_block(block);
    7878        }
    79        
     79
    8080        while ((link = list_first(&mem_areas)) != NULL) {
    8181                mem_area_t *area = list_get_instance(link, mem_area_t, link);
     
    8989        uint8_t *mbeg = (uint8_t *) block;
    9090        uint8_t *mend = (uint8_t *) block + sizeof(mem_block_t);
    91        
     91
    9292        /* Entry block memory <bbeg, bend) */
    9393        uint8_t *bbeg = (uint8_t *) block->addr;
    9494        uint8_t *bend = (uint8_t *) block->addr + block->size;
    95        
     95
    9696        /* Data block <dbeg, dend) */
    9797        uint8_t *dbeg = (uint8_t *) addr;
    9898        uint8_t *dend = (uint8_t *) addr + size;
    99        
     99
    100100        /* Check for overlaps */
    101101        if (((mbeg >= dbeg) && (mbeg < dend)) ||
     
    104104            ((bend > dbeg) && (bend <= dend)))
    105105                return true;
    106        
     106
    107107        return false;
    108108}
     
    122122{
    123123        bool fnd = false;
    124        
     124
    125125        list_foreach(mem_blocks, link, mem_block_t, block) {
    126126                if (overlap_match(block, addr, size)) {
     
    129129                }
    130130        }
    131        
     131
    132132        return fnd;
    133133}
     
    160160{
    161161        void *data;
    162        
     162
    163163        /* Allocate the chunk of memory */
    164164        data = malloc(size);
     
    166166        if (data == NULL)
    167167                return NULL;
    168        
     168
    169169        /* Check for overlaps with other chunks */
    170170        if (test_overlap(data, size)) {
     
    174174                error_flag = true;
    175175        }
    176        
     176
    177177        return data;
    178178}
     
    197197        if (mem_allocated >= MAX_ALLOC)
    198198                return NULL;
    199        
     199
    200200        /* Allocate the block holder */
    201201        mem_block_t *block =
     
    203203        if (block == NULL)
    204204                return NULL;
    205        
     205
    206206        link_initialize(&block->link);
    207        
     207
    208208        /* Allocate the block memory */
    209209        block->addr = checked_malloc(size);
     
    213213                return NULL;
    214214        }
    215        
     215
    216216        block->size = size;
    217        
     217
    218218        /* Register the allocated block */
    219219        list_append(&block->link, &mem_blocks);
    220220        mem_allocated += size + sizeof(mem_block_t);
    221221        mem_blocks_count++;
    222        
     222
    223223        return block;
    224224}
     
    238238        mem_allocated -= block->size + sizeof(mem_block_t);
    239239        mem_blocks_count--;
    240        
     240
    241241        /* Free the memory */
    242242        free(block->addr);
     
    272272            pos < end; pos++)
    273273                *pos = block_expected_value(block, pos);
    274        
     274
    275275        check_consistency("fill_block");
    276276}
     
    308308        if (mem_blocks_count == 0)
    309309                return NULL;
    310        
     310
    311311        unsigned long idx = rand() % mem_blocks_count;
    312312        link_t *entry = list_nth(&mem_blocks, idx);
    313        
     313
    314314        if (entry == NULL) {
    315315                TPRINTF("\nError: Corrupted list of allocated memory blocks.\n");
     
    317317                error_flag = true;
    318318        }
    319        
     319
    320320        return list_get_instance(entry, mem_block_t, link);
    321321}
     
    337337        if (area == NULL)
    338338                return NULL;
    339        
     339
    340340        link_initialize(&area->link);
    341        
     341
    342342        area->addr = as_area_create(AS_AREA_ANY, size,
    343343            AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE,
     
    348348                return NULL;
    349349        }
    350        
     350
    351351        area->size = size;
    352        
     352
    353353        /* Register the allocated area */
    354354        list_append(&area->link, &mem_areas);
    355        
     355
    356356        return area;
    357357}
     
    369369        /* Unregister the area */
    370370        list_remove(&area->link);
    371        
     371
    372372        /* Free the memory */
    373373        errno_t ret = as_area_destroy(area->addr);
    374374        if (ret != EOK)
    375375                error_flag = true;
    376        
     376
    377377        free(area);
    378378        check_consistency("unmap_area");
     
    405405            pos < end; pos++)
    406406                *pos = area_expected_value(area, pos);
    407        
     407
    408408        check_consistency("fill_area");
    409409}
Note: See TracChangeset for help on using the changeset viewer.