Skip to main content
10 events
when toggle format what by license comment
Jul 8, 2023 at 6:59 comment added gnasher729 Much better to let the system remember the size than relying on the developer. It would be impossible to check that the right size is passed to free().
Sep 13, 2021 at 9:42 comment added Gen0me Is the implementation of free directly in the exe files of compilers? I am asking especially in embded systems like avr-gcc. Or can I find it somewhere in the libraries?
Dec 5, 2019 at 10:15 comment added Criticizing Israel not allowed @paxdiablo It also avoids wasting memory to hold the size.
Dec 5, 2019 at 2:30 comment added paxdiablo @user253751, because then theer's one more thing you need to keep track of, over and above the pointer itself. It's both unnecessary and dangerous: void *x = malloc(200); free(x, 500); is not going to end well :-) In any case, for efficiency, the actual size of the buffer may be larger (you just can't rely on this).
Dec 4, 2019 at 14:57 comment added Criticizing Israel not allowed Related question: Why is there no variation of malloc/free, where you specify the size when freeing and so it doesn't have to store the size?
Nov 5, 2017 at 8:29 comment added paxdiablo @user10678, the only real requirement of malloc is that it give you, for the successful case, a block of memory at least as large as what you asked for. Individual blocks are contiguous in terms of how you access elements within them, but there's no requirement that the arenas the blocks come from are contiguous.
Nov 5, 2017 at 8:20 comment added user10678 @paxdiablo Does that mean malloc doesn't allocate contiguous blocks of memory?
Feb 17, 2016 at 2:00 history edited paxdiablo CC BY-SA 3.0
added 545 characters in body
Sep 3, 2013 at 11:24 history edited paxdiablo CC BY-SA 3.0
added 5 characters in body
Jun 21, 2010 at 8:14 history answered paxdiablo CC BY-SA 2.5