News for hackers. Stuff that matters.
Re:Show HN by estebank on Saturday December 03, 2022 @01:36PM (#33846004)
How would this colocation of the string pointer work? Because these would be in the heap, right? Otherwise the pointer would get invalidated as soon as the enclosing function ends and its stack frame gets discarded. So if it is in the heap then you either have a pointer to the colocated pointer (not very useful, if negligible performance impact) or you're copying the colocated pointer (at which point you're back to square one, having a pointer in the stack and the underlying string in the heap). Am I missing something?
Re:Show HN by alcover on Saturday December 03, 2022 @02:45PM (#33846601)
Good point. Some SSO (small str optimization) schemes achieve this by pointing back into the struct itself. Gcc String implementation for ex.