|
Lines 7-15
Link Here
|
| 7 |
*/ |
7 |
*/ |
| 8 |
int kde_malloc_is_used = 0; |
8 |
int kde_malloc_is_used = 0; |
| 9 |
|
9 |
|
| 10 |
#ifdef KDE_MALLOC |
10 |
#ifdef TDE_MALLOC |
| 11 |
|
11 |
|
| 12 |
#ifdef KDE_MALLOC_DEBUG |
12 |
#ifdef TDE_MALLOC_DEBUG |
| 13 |
#define DEBUG |
13 |
#define DEBUG |
| 14 |
#endif |
14 |
#endif |
| 15 |
|
15 |
|
|
Lines 1559-1565
Link Here
|
| 1559 |
|
1559 |
|
| 1560 |
#else |
1560 |
#else |
| 1561 |
|
1561 |
|
| 1562 |
#ifdef KDE_MALLOC_X86 |
1562 |
#ifdef TDE_MALLOC_X86 |
| 1563 |
#include "x86.h" |
1563 |
#include "x86.h" |
| 1564 |
#else |
1564 |
#else |
| 1565 |
#error Unknown spinlock implementation |
1565 |
#error Unknown spinlock implementation |
|
Lines 5475-5483
Link Here
|
| 5475 |
|
5475 |
|
| 5476 |
#ifdef USE_PUBLIC_MALLOC_WRAPPERS |
5476 |
#ifdef USE_PUBLIC_MALLOC_WRAPPERS |
| 5477 |
|
5477 |
|
| 5478 |
#ifndef KDE_MALLOC_FULL |
5478 |
#ifndef TDE_MALLOC_FULL |
| 5479 |
|
5479 |
|
| 5480 |
#ifdef KDE_MALLOC_GLIBC |
5480 |
#ifdef TDE_MALLOC_GLIBC |
| 5481 |
#include "glibc.h" |
5481 |
#include "glibc.h" |
| 5482 |
#else |
5482 |
#else |
| 5483 |
/* cannot use dlsym(RTLD_NEXT,...) here, it calls malloc()*/ |
5483 |
/* cannot use dlsym(RTLD_NEXT,...) here, it calls malloc()*/ |
|
Lines 5491-5497
Link Here
|
| 5491 |
static int malloc_type = 0; |
5491 |
static int malloc_type = 0; |
| 5492 |
static void init_malloc_type(void) |
5492 |
static void init_malloc_type(void) |
| 5493 |
{ |
5493 |
{ |
| 5494 |
const char* const env = getenv( "KDE_MALLOC" ); |
5494 |
const char* const env = getenv( "TDE_MALLOC" ); |
| 5495 |
if( env == NULL ) |
5495 |
if( env == NULL ) |
| 5496 |
malloc_type = 1; |
5496 |
malloc_type = 1; |
| 5497 |
else if( env[ 0 ] == '0' || env[ 0 ] == 'n' || env[ 0 ] == 'N' ) |
5497 |
else if( env[ 0 ] == '0' || env[ 0 ] == 'n' || env[ 0 ] == 'N' ) |
|
Lines 5503-5509
Link Here
|
| 5503 |
#endif |
5503 |
#endif |
| 5504 |
|
5504 |
|
| 5505 |
Void_t* public_mALLOc(size_t bytes) { |
5505 |
Void_t* public_mALLOc(size_t bytes) { |
| 5506 |
#ifndef KDE_MALLOC_FULL |
5506 |
#ifndef TDE_MALLOC_FULL |
| 5507 |
if( malloc_type == 1 ) |
5507 |
if( malloc_type == 1 ) |
| 5508 |
{ |
5508 |
{ |
| 5509 |
#endif |
5509 |
#endif |
|
Lines 5515-5521
Link Here
|
| 5515 |
if (MALLOC_POSTACTION != 0) { |
5515 |
if (MALLOC_POSTACTION != 0) { |
| 5516 |
} |
5516 |
} |
| 5517 |
return m; |
5517 |
return m; |
| 5518 |
#ifndef KDE_MALLOC_FULL |
5518 |
#ifndef TDE_MALLOC_FULL |
| 5519 |
} |
5519 |
} |
| 5520 |
if( malloc_type == 2 ) |
5520 |
if( malloc_type == 2 ) |
| 5521 |
return libc_malloc( bytes ); |
5521 |
return libc_malloc( bytes ); |
|
Lines 5525-5531
Link Here
|
| 5525 |
} |
5525 |
} |
| 5526 |
|
5526 |
|
| 5527 |
void public_fREe(Void_t* m) { |
5527 |
void public_fREe(Void_t* m) { |
| 5528 |
#ifndef KDE_MALLOC_FULL |
5528 |
#ifndef TDE_MALLOC_FULL |
| 5529 |
if( malloc_type == 1 ) |
5529 |
if( malloc_type == 1 ) |
| 5530 |
{ |
5530 |
{ |
| 5531 |
#endif |
5531 |
#endif |
|
Lines 5535-5541
Link Here
|
| 5535 |
fREe(m); |
5535 |
fREe(m); |
| 5536 |
if (MALLOC_POSTACTION != 0) { |
5536 |
if (MALLOC_POSTACTION != 0) { |
| 5537 |
} |
5537 |
} |
| 5538 |
#ifndef KDE_MALLOC_FULL |
5538 |
#ifndef TDE_MALLOC_FULL |
| 5539 |
return; |
5539 |
return; |
| 5540 |
} |
5540 |
} |
| 5541 |
if( malloc_type == 2 ) |
5541 |
if( malloc_type == 2 ) |
|
Lines 5549-5555
Link Here
|
| 5549 |
} |
5549 |
} |
| 5550 |
|
5550 |
|
| 5551 |
Void_t* public_rEALLOc(Void_t* m, size_t bytes) { |
5551 |
Void_t* public_rEALLOc(Void_t* m, size_t bytes) { |
| 5552 |
#ifndef KDE_MALLOC_FULL |
5552 |
#ifndef TDE_MALLOC_FULL |
| 5553 |
if( malloc_type == 1 ) |
5553 |
if( malloc_type == 1 ) |
| 5554 |
{ |
5554 |
{ |
| 5555 |
#endif |
5555 |
#endif |
|
Lines 5560-5566
Link Here
|
| 5560 |
if (MALLOC_POSTACTION != 0) { |
5560 |
if (MALLOC_POSTACTION != 0) { |
| 5561 |
} |
5561 |
} |
| 5562 |
return m; |
5562 |
return m; |
| 5563 |
#ifndef KDE_MALLOC_FULL |
5563 |
#ifndef TDE_MALLOC_FULL |
| 5564 |
} |
5564 |
} |
| 5565 |
if( malloc_type == 2 ) |
5565 |
if( malloc_type == 2 ) |
| 5566 |
return libc_realloc( m, bytes ); |
5566 |
return libc_realloc( m, bytes ); |
|
Lines 5570-5576
Link Here
|
| 5570 |
} |
5570 |
} |
| 5571 |
|
5571 |
|
| 5572 |
Void_t* public_mEMALIGn(size_t alignment, size_t bytes) { |
5572 |
Void_t* public_mEMALIGn(size_t alignment, size_t bytes) { |
| 5573 |
#ifndef KDE_MALLOC_FULL |
5573 |
#ifndef TDE_MALLOC_FULL |
| 5574 |
if( malloc_type == 1 ) |
5574 |
if( malloc_type == 1 ) |
| 5575 |
{ |
5575 |
{ |
| 5576 |
#endif |
5576 |
#endif |
|
Lines 5582-5588
Link Here
|
| 5582 |
if (MALLOC_POSTACTION != 0) { |
5582 |
if (MALLOC_POSTACTION != 0) { |
| 5583 |
} |
5583 |
} |
| 5584 |
return m; |
5584 |
return m; |
| 5585 |
#ifndef KDE_MALLOC_FULL |
5585 |
#ifndef TDE_MALLOC_FULL |
| 5586 |
} |
5586 |
} |
| 5587 |
if( malloc_type == 2 ) |
5587 |
if( malloc_type == 2 ) |
| 5588 |
return libc_memalign( alignment, bytes ); |
5588 |
return libc_memalign( alignment, bytes ); |
|
Lines 5592-5598
Link Here
|
| 5592 |
} |
5592 |
} |
| 5593 |
|
5593 |
|
| 5594 |
Void_t* public_vALLOc(size_t bytes) { |
5594 |
Void_t* public_vALLOc(size_t bytes) { |
| 5595 |
#ifndef KDE_MALLOC_FULL |
5595 |
#ifndef TDE_MALLOC_FULL |
| 5596 |
if( malloc_type == 1 ) |
5596 |
if( malloc_type == 1 ) |
| 5597 |
{ |
5597 |
{ |
| 5598 |
#endif |
5598 |
#endif |
|
Lines 5604-5610
Link Here
|
| 5604 |
if (MALLOC_POSTACTION != 0) { |
5604 |
if (MALLOC_POSTACTION != 0) { |
| 5605 |
} |
5605 |
} |
| 5606 |
return m; |
5606 |
return m; |
| 5607 |
#ifndef KDE_MALLOC_FULL |
5607 |
#ifndef TDE_MALLOC_FULL |
| 5608 |
} |
5608 |
} |
| 5609 |
if( malloc_type == 2 ) |
5609 |
if( malloc_type == 2 ) |
| 5610 |
return libc_valloc( bytes ); |
5610 |
return libc_valloc( bytes ); |
|
Lines 5614-5620
Link Here
|
| 5614 |
} |
5614 |
} |
| 5615 |
|
5615 |
|
| 5616 |
Void_t* public_pVALLOc(size_t bytes) { |
5616 |
Void_t* public_pVALLOc(size_t bytes) { |
| 5617 |
#ifndef KDE_MALLOC_FULL |
5617 |
#ifndef TDE_MALLOC_FULL |
| 5618 |
if( malloc_type == 1 ) |
5618 |
if( malloc_type == 1 ) |
| 5619 |
{ |
5619 |
{ |
| 5620 |
#endif |
5620 |
#endif |
|
Lines 5626-5632
Link Here
|
| 5626 |
if (MALLOC_POSTACTION != 0) { |
5626 |
if (MALLOC_POSTACTION != 0) { |
| 5627 |
} |
5627 |
} |
| 5628 |
return m; |
5628 |
return m; |
| 5629 |
#ifndef KDE_MALLOC_FULL |
5629 |
#ifndef TDE_MALLOC_FULL |
| 5630 |
} |
5630 |
} |
| 5631 |
if( malloc_type == 2 ) |
5631 |
if( malloc_type == 2 ) |
| 5632 |
return libc_pvalloc( bytes ); |
5632 |
return libc_pvalloc( bytes ); |
|
Lines 5636-5642
Link Here
|
| 5636 |
} |
5636 |
} |
| 5637 |
|
5637 |
|
| 5638 |
Void_t* public_cALLOc(size_t n, size_t elem_size) { |
5638 |
Void_t* public_cALLOc(size_t n, size_t elem_size) { |
| 5639 |
#ifndef KDE_MALLOC_FULL |
5639 |
#ifndef TDE_MALLOC_FULL |
| 5640 |
if( malloc_type == 1 ) |
5640 |
if( malloc_type == 1 ) |
| 5641 |
{ |
5641 |
{ |
| 5642 |
#endif |
5642 |
#endif |
|
Lines 5648-5654
Link Here
|
| 5648 |
if (MALLOC_POSTACTION != 0) { |
5648 |
if (MALLOC_POSTACTION != 0) { |
| 5649 |
} |
5649 |
} |
| 5650 |
return m; |
5650 |
return m; |
| 5651 |
#ifndef KDE_MALLOC_FULL |
5651 |
#ifndef TDE_MALLOC_FULL |
| 5652 |
} |
5652 |
} |
| 5653 |
if( malloc_type == 2 ) |
5653 |
if( malloc_type == 2 ) |
| 5654 |
return libc_calloc( n, elem_size ); |
5654 |
return libc_calloc( n, elem_size ); |
|
Lines 5658-5664
Link Here
|
| 5658 |
} |
5658 |
} |
| 5659 |
|
5659 |
|
| 5660 |
void public_cFREe(Void_t* m) { |
5660 |
void public_cFREe(Void_t* m) { |
| 5661 |
#ifndef KDE_MALLOC_FULL |
5661 |
#ifndef TDE_MALLOC_FULL |
| 5662 |
if( malloc_type == 1 ) |
5662 |
if( malloc_type == 1 ) |
| 5663 |
{ |
5663 |
{ |
| 5664 |
#endif |
5664 |
#endif |
|
Lines 5668-5674
Link Here
|
| 5668 |
cFREe(m); |
5668 |
cFREe(m); |
| 5669 |
if (MALLOC_POSTACTION != 0) { |
5669 |
if (MALLOC_POSTACTION != 0) { |
| 5670 |
} |
5670 |
} |
| 5671 |
#ifndef KDE_MALLOC_FULL |
5671 |
#ifndef TDE_MALLOC_FULL |
| 5672 |
return; |
5672 |
return; |
| 5673 |
} |
5673 |
} |
| 5674 |
if( malloc_type == 2 ) |
5674 |
if( malloc_type == 2 ) |
|
Lines 5682-5688
Link Here
|
| 5682 |
} |
5682 |
} |
| 5683 |
|
5683 |
|
| 5684 |
struct mallinfo public_mALLINFo() { |
5684 |
struct mallinfo public_mALLINFo() { |
| 5685 |
#ifndef KDE_MALLOC_FULL |
5685 |
#ifndef TDE_MALLOC_FULL |
| 5686 |
if( malloc_type == 1 ) |
5686 |
if( malloc_type == 1 ) |
| 5687 |
{ |
5687 |
{ |
| 5688 |
#endif |
5688 |
#endif |
|
Lines 5695-5701
Link Here
|
| 5695 |
if (MALLOC_POSTACTION != 0) { |
5695 |
if (MALLOC_POSTACTION != 0) { |
| 5696 |
} |
5696 |
} |
| 5697 |
return m; |
5697 |
return m; |
| 5698 |
#ifndef KDE_MALLOC_FULL |
5698 |
#ifndef TDE_MALLOC_FULL |
| 5699 |
} |
5699 |
} |
| 5700 |
if( malloc_type == 2 ) |
5700 |
if( malloc_type == 2 ) |
| 5701 |
return libc_mallinfo(); |
5701 |
return libc_mallinfo(); |
|
Lines 5705-5711
Link Here
|
| 5705 |
} |
5705 |
} |
| 5706 |
|
5706 |
|
| 5707 |
int public_mALLOPt(int p, int v) { |
5707 |
int public_mALLOPt(int p, int v) { |
| 5708 |
#ifndef KDE_MALLOC_FULL |
5708 |
#ifndef TDE_MALLOC_FULL |
| 5709 |
if( malloc_type == 1 ) |
5709 |
if( malloc_type == 1 ) |
| 5710 |
{ |
5710 |
{ |
| 5711 |
#endif |
5711 |
#endif |
|
Lines 5717-5723
Link Here
|
| 5717 |
if (MALLOC_POSTACTION != 0) { |
5717 |
if (MALLOC_POSTACTION != 0) { |
| 5718 |
} |
5718 |
} |
| 5719 |
return result; |
5719 |
return result; |
| 5720 |
#ifndef KDE_MALLOC_FULL |
5720 |
#ifndef TDE_MALLOC_FULL |
| 5721 |
} |
5721 |
} |
| 5722 |
if( malloc_type == 2 ) |
5722 |
if( malloc_type == 2 ) |
| 5723 |
return libc_mallopt( p, v ); |
5723 |
return libc_mallopt( p, v ); |