summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/malloc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* use _ALIGN() which is uhm a bit OpenBSD-specific, but it means wederaadt2018-03-061-3/+2
| | | | | | don't need to use sys/param.h at all, guess which one i believe is greater namespace polution ok otto
* Use _MAX_PAGE_SHIFT, rather than #ifdef mips64deraadt2018-03-051-6/+2
| | | | ok guenther kettenis
* use consistent style for for loop in unmap(), no functional changeotto2018-02-071-4/+2
|
* keep in sync with ld.so malloc.cotto2018-01-301-2/+3
|
* - An error in the multithreaded case could print the wrong function nameotto2018-01-281-12/+23
| | | | | | | - Start with a full page of struct region_info's - Save an mprotect in the init code: allocate 3 pages with none and make the middle page r/w instead of a r/w allocation and two calls to make the guard pages none
* - do not junk pages returned by free_bytes(), all freed chunks are alreadyotto2018-01-261-19/+19
| | | | | junked - freezero(): only clear requested size
* Zap the rotor, it was a wrong idea. Cluebat applied by kshe whootto2018-01-181-6/+3
| | | | | came also up with this diff. Simple, no bias and benchmarks show the extra random calls disappear in te measurement noise.
* Move to ffs(3) for bitmask scanning. I played with this earlier,otto2018-01-181-21/+11
| | | | | | | but at that time ffs function calls were generated instead of the compiler inlining the code. Now that ffs is marked protected in libc this is handled better. Thanks to kshe who prompted me to look at this again.
* optimization and some cleanup; mostly from kshe (except the unmap() part)otto2018-01-081-67/+51
|
* Only init chunk_info once, plus some moving of code to group related functions.otto2018-01-011-273/+267
|
* step one in avoiding unneccesary init of chunk_info;otto2017-12-271-65/+81
| | | | some cleanup; tested by sthen@ on a ports build
* 's' should include 'f'; from Jacqueline Jolicoeurotto2017-11-021-2/+2
|
* Restore a return that was inadvertently removed from freezero() in r1.234,jsing2017-10-191-1/+2
| | | | | | | which results in an internal double free when internal functions are not in use. ok otto@
* do not return f() where f is a void function; loop var type fixotto2017-10-051-4/+5
|
* Use dprintf instead of snprintf/writeotto2017-10-051-82/+36
|
* Make delayed free non-optional and make F do an extensive double free check.otto2017-09-231-21/+26
| | | | ok tb@ tedu@
* mapalign returns MAP_FAILED for failuer; from George Koehlerotto2017-09-121-2/+2
|
* check double free before canary for chunks; ok millert@otto2017-09-111-5/+5
|
* two MALLOC_STATS only tweaks; one from David CARLIER, the other found by clangotto2017-08-201-8/+4
|
* one more instance of the previous commit; also initialize ->offset to aotto2017-07-101-2/+3
| | | | definite value in the size == 0 case
* Only access offset if canaries are enabled *and* size > 0, otherwise offsetotto2017-07-071-2/+2
| | | | is not initialized. Problem spotted by Carlin Bingham; ok phessler@ tedu@
* port the RBT code to userland by making it part of libc.dlg2017-06-191-10/+11
| | | | | | | | | | | | | | src/lib/libc/gen/tree.c is a copy of src/sys/kern/subr_tree.c, but with annotations for symbol visibility. changes to one should be reflected in the other. the malloc debug code that uses RB code is ported to RBT. because libc provides the RBT code, procmap doesn't have to reach into the kernel and build subr_tree.c itself now. mild enthusiasm from many ok guenther@
* - fix bug wrt posix_memalign(3) of blocks between half a page and a pageotto2017-05-131-4/+9
| | | | | - document posix_memalign() does not play nice with reacallocarray(3) and freezero(3)
* For small allocations (chunk) freezero only validates the givenotto2017-04-221-5/+10
| | | | | | | | size if canaries are enabled. In that case we have the exact requested size of the allocation. But we can at least check the given size against the chunk size if C is not enabled. Plus add some braces so my brain doesn't have to scan for dangling else problems when I see this code.
* don't forget to fill in canary bytes for posix_memalign(3); reported byotto2017-04-181-1/+4
| | | | and ok jeremy@
* whitespace fixesotto2017-04-171-14/+14
|
* allow clearing less than allocated and document freezero(3) betterotto2017-04-131-5/+5
|
* Introducing freezero(3) a version of free that guarantees the processotto2017-04-101-12/+72
| | | | | | no longer has access to the content of a memmory object. It does this by either clearing (if the object memory remains cached) or by calling munmap(2). ok millert@, deraadt@, guenther@
* first print size in meta-data then supplied arg size when an inconsistency isotto2017-04-061-3/+3
| | | | detected wrt recallocarray()
* small cleanup & optimization; ok deraadt@ millert@otto2017-03-281-2/+5
|
* add a helper function to print all pools #ifdef MALLOC_STATSotto2017-03-241-1/+16
| | | | from David CARLIER
* move recallocarray to malloc.c andotto2017-03-241-17/+206
| | | | | | | - use internal meta-data to do more consistency checking (especially with option C) - use cheap free if possible ok deraadt@
* Add a NULL test to wrterror() to avoid a NULL deref when called from ajsg2017-02-151-2/+2
| | | | | | free() error path. ok otto@
* fix a comment and rm some dead code as a result of the previous diffotto2017-02-021-8/+5
|
* Let realloc handle and produce moved pointers for allocations betweenlibressl-v2.5.1otto2017-02-011-20/+37
| | | | half a page and a page. ok jmatthew@ tb@
* 1. When shrinking a chunk allocation, compare the size of the currentotto2017-01-211-46/+87
| | | | | | | | | | allocation to the size of the new allocation (instead of the requested size). 2. Previously realloc takes the easy way and always reallocates if C is active. This commit fixes by carefully updating the recorded requested size in all cases, and writing the canary bytes in the proper location after reallocating. 3. Introduce defines to test if MALLOC_MOVE should be done and to compute the new value.
* MALLOC_STATS tweaks, by default not compiled inotto2016-11-041-13/+29
|
* small tweak to also check canaries if F is in effectotto2016-11-031-3/+5
|
* remove some old option letters and also make P non-settable. It hasotto2016-10-311-24/+6
| | | | | been the default for ages, and I see no valid reason to be able to disable it. ok natano@
* Pages in the malloc cache are either reused quickly or unmappedotto2016-10-281-14/+1
| | | | | | quickly. In both cases it does not make sense to set hints on them. So remove that option, which is just a remainder of old times when malloc used to hold on to pages. ok stefan@
* - fix MALLOC_STATS compileotto2016-10-221-3/+6
| | | | - redundant cast is redundant
* fix some void * arithmetic by castingotto2016-10-211-4/+4
|
* and recommit with fixed GCotto2016-10-211-103/+112
|
* backout for now; flag combination GC is not okotto2016-10-201-110/+103
|
* Also place canaries in > page sized objects (if C is in effect); ok tb@otto2016-10-201-103/+110
|
* Wrap _malloc_init() so internal calls go directlyguenther2016-10-151-1/+2
| | | | | prodded by otto@ ok kettenis@ otto@
* 0xd0 -> 0xdb; ok deraadt@ millert@ tedu@otto2016-10-141-3/+3
|
* optimize canary code a bit by storing offset of sizes table instead ofotto2016-10-121-5/+7
| | | | recomputing it all the time
* stray tabotto2016-10-071-2/+2
|
* Beter implementation of chunk canaries: store size in chunk meta dataotto2016-10-071-61/+63
| | | | instead of chunk itself; does not change actual allocated size; ok tedu@