6 ms·
It's certainly not the style I would expect C to be written these days, but I don't think it's terrible code. It was, 40 years ago, genuine shipping real-world
by pm215 9y ago
It's certainly not the style I would expect C to be written these days, but I don't think it's terrible code. It was, 40 years ago, genuine shipping real-world code. There's a related quote about this in the foreword that Dennis Ritchie wrote for the reprint of the Lions commentary:
"You will find linear searches, primitive data structures, C code that wouldn't compile in 1979 let alone today, and an orientation towards a machine that's little more than a memory. But you will also see in the code an underlying structure that has lasted for a long time and has managed to accommodate vast changes in the computing environment." We're still calling malloc() and free() and realloc() today with the semantics that the Unix designers assigned them in the 1970s, even if the underlying implementations are significantly different. The bones of the design are strong; the initial implementations may have been naive but they were good enough to ship (and remember there were only a fairly small group of people writing the whole OS and userland).
- hawski 9y agoIt seems that it's not entirely the same semantics: https://www.spinellis.gr/blog/20170914/ https://www.spinellis.gr/blog/20170914/ ( https://news.ycombinator.com/item?id=15246690 https://news.ycombinator.com/item?id=15246690 )
- pm215 9y agoThat blog post is talking about the kernel's internal allocator, not the libc one.