Commit cc61de2
Use posix_memalign in custom heap allocation config
Replace aligned_alloc + MLK_ALIGN_UP with posix_memalign in
custom_heap_alloc_config.h. Unlike aligned_alloc, posix_memalign
does not require the size to be a multiple of the alignment,
removing the need for MLK_ALIGN_UP rounding. This ensures that
allocations are exact-sized, allowing memory-safety tests like
valgrind and ASan to detect overflows at precise buffer boundaries.
On Windows, where posix_memalign is not available, we use
_aligned_malloc instead. This, too, does not require the size
to be a multiple of the alignment.
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>1 parent 13aa41a commit cc61de2
2 files changed
Lines changed: 39 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
400 | 403 | | |
401 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
402 | 411 | | |
403 | | - | |
404 | | - | |
405 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
406 | 421 | | |
| 422 | + | |
407 | 423 | | |
408 | 424 | | |
409 | 425 | | |
| |||
449 | 465 | | |
450 | 466 | | |
451 | 467 | | |
452 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
501 | 504 | | |
502 | 505 | | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
503 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
504 | 522 | | |
505 | | - | |
| 523 | + | |
506 | 524 | | |
| 525 | + | |
507 | 526 | | |
508 | 527 | | |
509 | 528 | | |
| |||
0 commit comments