4 ms·
You're joking. There's a very serious distinction between the stack and the heap - perhaps they live in the same memory but they are used very differently and i
by Sir_Cmpwn 8y ago
You're joking. There's a very serious distinction between the stack and the heap - perhaps they live in the same memory but they are used very differently and if you mix them up your things will break.
- rrauenza 8y ago...like returning a pointer to the stack: char *dupstr(const char *src) { char new[1024]; strlcpy(new, src, 1024); return new; }
- TheOtherHobbes 8y agoThere is no hardware distinction between stack memory and heap memory. In fact C teaches a model of a semi-standard virtual architecture - loosely based on the DEC PDP7 and/or PDP11 - which is long gone from real hardware. Real hardware today has multiple abstraction layers under the assembly code, and all but the top layer is inaccessible. So there's no single definitive model of "How computers work." They work at whatever level of abstraction you need them to work. You should definitely be familiar with a good selection of levels - and unless you're doing chip design, they're all equally real.
- arcticbull 8y agoThere definitely is, unless there's a hardware heap pointer and hardware allocation and deallocation instructions, as there are for the stack :)
- Sir_Cmpwn 8y agoThis isn't true. Modern instruction sets have clearly been influenced by and designed to optimize the C ABI.