~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/mem/mem0mem.c

  • Committer: Monty Taylor
  • Date: 2010-10-12 20:20:44 UTC
  • mto: (1842.1.3 build) (1843.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1843.
  • Revision ID: mordred@inaugust.com-20101012202044-yfrmnmkznvkqfxe4
Added support for valgrind suppressions.
Run strip-valgrind as part of make valgrind.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
347
347
                                return(NULL);
348
348
                        }
349
349
                } else {
350
 
                        buf_block = buf_block_alloc(NULL, 0);
 
350
                        buf_block = buf_block_alloc(0);
351
351
                }
352
352
 
353
353
                block = (mem_block_t*) buf_block->frame;
367
367
        block->line = line;
368
368
 
369
369
#ifdef MEM_PERIODIC_CHECK
370
 
        mutex_enter(&(mem_comm_pool->mutex));
 
370
        mem_pool_mutex_enter();
371
371
 
372
372
        if (!mem_block_list_inited) {
373
373
                mem_block_list_inited = TRUE;
376
376
 
377
377
        UT_LIST_ADD_LAST(mem_block_list, mem_block_list, block);
378
378
 
379
 
        mutex_exit(&(mem_comm_pool->mutex));
 
379
        mem_pool_mutex_exit();
380
380
#endif
381
381
        mem_block_set_len(block, len);
382
382
        mem_block_set_type(block, type);
383
383
        mem_block_set_free(block, MEM_BLOCK_HEADER_SIZE);
384
384
        mem_block_set_start(block, MEM_BLOCK_HEADER_SIZE);
385
385
 
386
 
        if (UNIV_UNLIKELY(heap == NULL)) {
387
 
                /* This is the first block of the heap. The field
388
 
                total_size should be initialized here */
389
 
                block->total_size = len;
390
 
        } else {
391
 
                /* Not the first allocation for the heap. This block's
392
 
                total_length field should be set to undefined. */
393
 
                ut_d(block->total_size = ULINT_UNDEFINED);
394
 
                UNIV_MEM_INVALID(&block->total_size,
395
 
                                 sizeof block->total_size);
396
 
 
397
 
                heap->total_size += len;
398
 
        }
399
 
 
400
386
        ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len);
401
387
 
402
388
        return(block);
479
465
        UT_LIST_REMOVE(list, heap->base, block);
480
466
 
481
467
#ifdef MEM_PERIODIC_CHECK
482
 
        mutex_enter(&(mem_comm_pool->mutex));
 
468
        mem_pool_mutex_enter();
483
469
 
484
470
        UT_LIST_REMOVE(mem_block_list, mem_block_list, block);
485
471
 
486
 
        mutex_exit(&(mem_comm_pool->mutex));
 
472
        mem_pool_mutex_exit();
487
473
#endif
488
 
 
489
 
        ut_ad(heap->total_size >= block->len);
490
 
        heap->total_size -= block->len;
491
 
 
492
474
        type = heap->type;
493
475
        len = block->len;
494
476
        block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
495
477
 
496
 
#ifndef UNIV_HOTBACKUP
497
478
#ifdef UNIV_MEM_DEBUG
498
479
        /* In the debug version we set the memory to a random combination
499
480
        of hex 0xDE and 0xAD. */
503
484
        UNIV_MEM_ASSERT_AND_FREE(block, len);
504
485
#endif /* UNIV_MEM_DEBUG */
505
486
 
 
487
#ifndef UNIV_HOTBACKUP
506
488
        if (type == MEM_HEAP_DYNAMIC || len < UNIV_PAGE_SIZE / 2) {
507
489
 
508
490
                ut_ad(!buf_block);
513
495
                buf_block_free(buf_block);
514
496
        }
515
497
#else /* !UNIV_HOTBACKUP */
516
 
#ifdef UNIV_MEM_DEBUG
517
 
        /* In the debug version we set the memory to a random
518
 
        combination of hex 0xDE and 0xAD. */
519
 
 
520
 
        mem_erase_buf((byte*)block, len);
521
 
#else /* UNIV_MEM_DEBUG */
522
 
        UNIV_MEM_ASSERT_AND_FREE(block, len);
523
 
#endif /* UNIV_MEM_DEBUG */
524
498
        ut_free(block);
525
499
#endif /* !UNIV_HOTBACKUP */
526
500
}
554
528
{
555
529
        mem_block_t*    block;
556
530
 
557
 
        mutex_enter(&(mem_comm_pool->mutex));
 
531
        mem_pool_mutex_enter();
558
532
 
559
533
        block = UT_LIST_GET_FIRST(mem_block_list);
560
534
 
566
540
                block = UT_LIST_GET_NEXT(mem_block_list, block);
567
541
        }
568
542
 
569
 
        mutex_exit(&(mem_comm_pool->mutex));
 
543
        mem_pool_mutex_exit();
570
544
}
571
545
#endif