~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_goodfit_alloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • mto: (3.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
 
162
162
 
163
163
/* Prototypes of callback functions */
164
 
static Block_t *        get_free_block          (Allctr_t *, Uint);
 
164
static Block_t *        get_free_block          (Allctr_t *, Uint,
 
165
                                                 Block_t *, Uint);
165
166
static void             link_free_block         (Allctr_t *, Block_t *);
166
167
static void             unlink_free_block       (Allctr_t *, Block_t *);
167
168
static void             update_last_aux_mbc     (Allctr_t *, Carrier_t *);
376
377
}
377
378
 
378
379
static Block_t *
379
 
get_free_block(Allctr_t *allctr, Uint size)
 
380
get_free_block(Allctr_t *allctr, Uint size,
 
381
               Block_t *cand_blk, Uint cand_size)
380
382
{
381
383
    GFAllctr_t *gfallctr = (GFAllctr_t *) allctr;
382
384
    int unsafe_bi, min_bi;
383
385
    Block_t *blk;
384
386
 
 
387
    ASSERT(!cand_blk || cand_size >= size);
 
388
 
385
389
    unsafe_bi = BKT_IX(gfallctr, size);
386
390
    
387
391
    min_bi = find_bucket(&gfallctr->bucket_mask, unsafe_bi);
391
395
    if (min_bi == unsafe_bi) {
392
396
        blk = search_bucket(allctr, min_bi, size);
393
397
        if (blk) {
 
398
            if (cand_blk && cand_size <= BLK_SZ(blk))
 
399
                return NULL; /* cand_blk was better */
394
400
            unlink_free_block(allctr, blk);
395
401
            return blk;
396
402
        }
409
415
    /* We are guaranteed to find a block that fits in this bucket */
410
416
    blk = search_bucket(allctr, min_bi, size);
411
417
    ASSERT(blk);
 
418
    if (cand_blk && cand_size <= BLK_SZ(blk))
 
419
        return NULL; /* cand_blk was better */
412
420
    unlink_free_block(allctr, blk);
413
421
    return blk;
414
422
}