3
3
//
4
4
// The original source was written by Doug Lea and released to the public domain
5
5
6
+ macro_rules! debug_assert {
7
+ ( $( $arg: tt) * ) => {
8
+ if cfg!( all( feature = "debug" , debug_assertions) ) {
9
+ assert!( $( $arg) * ) ;
10
+ }
11
+ } ;
12
+ }
13
+
14
+ macro_rules! debug_assert_eq {
15
+ ( $( $arg: tt) * ) => {
16
+ if cfg!( all( feature = "debug" , debug_assertions) ) {
17
+ assert_eq!( $( $arg) * ) ;
18
+ }
19
+ } ;
20
+ }
21
+
6
22
use core:: cmp;
7
23
use core:: mem;
8
24
use core:: ptr;
@@ -1376,7 +1392,7 @@ impl<A: Allocator> Dlmalloc<A> {
1376
1392
// Sanity checks
1377
1393
1378
1394
unsafe fn check_any_chunk ( & self , p : * mut Chunk ) {
1379
- if !cfg ! ( debug_assertions) {
1395
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1380
1396
return ;
1381
1397
}
1382
1398
debug_assert ! (
@@ -1386,7 +1402,7 @@ impl<A: Allocator> Dlmalloc<A> {
1386
1402
}
1387
1403
1388
1404
unsafe fn check_top_chunk ( & self , p : * mut Chunk ) {
1389
- if !cfg ! ( debug_assertions) {
1405
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1390
1406
return ;
1391
1407
}
1392
1408
let sp = self . segment_holding ( p. cast ( ) ) ;
@@ -1407,7 +1423,7 @@ impl<A: Allocator> Dlmalloc<A> {
1407
1423
}
1408
1424
1409
1425
unsafe fn check_malloced_chunk ( & self , mem : * mut u8 , s : usize ) {
1410
- if !cfg ! ( debug_assertions) {
1426
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1411
1427
return ;
1412
1428
}
1413
1429
if mem. is_null ( ) {
@@ -1433,7 +1449,7 @@ impl<A: Allocator> Dlmalloc<A> {
1433
1449
}
1434
1450
1435
1451
unsafe fn check_mmapped_chunk ( & self , p : * mut Chunk ) {
1436
- if !cfg ! ( debug_assertions) {
1452
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1437
1453
return ;
1438
1454
}
1439
1455
let sz = Chunk :: size ( p) ;
@@ -1453,7 +1469,7 @@ impl<A: Allocator> Dlmalloc<A> {
1453
1469
}
1454
1470
1455
1471
unsafe fn check_free_chunk ( & self , p : * mut Chunk ) {
1456
- if !cfg ! ( debug_assertions) {
1472
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1457
1473
return ;
1458
1474
}
1459
1475
let sz = Chunk :: size ( p) ;
@@ -1478,7 +1494,7 @@ impl<A: Allocator> Dlmalloc<A> {
1478
1494
}
1479
1495
1480
1496
unsafe fn check_malloc_state ( & mut self ) {
1481
- if !cfg ! ( debug_assertions) {
1497
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1482
1498
return ;
1483
1499
}
1484
1500
for i in 0 ..NSMALLBINS_U32 {
@@ -1506,7 +1522,7 @@ impl<A: Allocator> Dlmalloc<A> {
1506
1522
}
1507
1523
1508
1524
unsafe fn check_smallbin ( & mut self , idx : u32 ) {
1509
- if !cfg ! ( debug_assertions) {
1525
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1510
1526
return ;
1511
1527
}
1512
1528
let b = self . smallbin_at ( idx) ;
@@ -1531,7 +1547,7 @@ impl<A: Allocator> Dlmalloc<A> {
1531
1547
}
1532
1548
1533
1549
unsafe fn check_treebin ( & mut self , idx : u32 ) {
1534
- if !cfg ! ( debug_assertions) {
1550
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1535
1551
return ;
1536
1552
}
1537
1553
let t = * self . treebin_at ( idx) ;
@@ -1545,7 +1561,7 @@ impl<A: Allocator> Dlmalloc<A> {
1545
1561
}
1546
1562
1547
1563
unsafe fn check_tree ( & mut self , t : * mut TreeChunk ) {
1548
- if !cfg ! ( debug_assertions) {
1564
+ if !cfg ! ( all ( feature = "debug" , debug_assertions) ) {
1549
1565
return ;
1550
1566
}
1551
1567
let tc = TreeChunk :: chunk ( t) ;
0 commit comments