A Sad Story About Temporary Buffers
A Sad Story about get_temporary_buffer When the C++ STL library was designed by the first author of this book, he realized that it would be helpful to have a function get_temporary_buffer that takes a size n and returns the largest available temporary buffer up to size n that fits into physical memory. As a placeholder (since the correct version needs to have knowledge that only the operating system has), he wrote a simplistic and impractical implementation, which repeatedly calls malloc asking for initially huge and gradually smaller chunks of memory until it returns a valid pointer. He put in a prominent comment in the code saying something like, “This is a bogus implementation, replace it!” To his surprise, he discovered years later that all the major vendors that provide STL implementations are still using this terrible implementation—but they removed his comment.
A book excerpt tells the story of a deliberately crude C++ implementation of get_temporary_buffer that was supposed to be replaced. Years later, major STL vendors were still using it, but had removed the warning comment. The joke is about temporary placeholder code becoming permanent production code. EN: A book excerpt tells the story of a deliberately crude C++ implementation of get_temporary_buffer that was supposed to be replaced. Years later, major STL vendors were still using it, but had removed the warning comment. The joke is about temporary placeholder code becoming permanent production code.
book page / страница книгиprinted text / печатный текстC++ code / код C++computer programming / компьютерное программированиеfunction name / имя функцииtemporary buffer / временный буферmemory / памятьoperating system / операционная системаmalloc call / вызов mallocpointer / указательcomment in code / комментарий в кодеbook excerpt / отрывок из книги
- @gentoomemes / 22034 2026-09-17
- Type
- image
- Size
- 800×436 · 90.0 KiB
- Mood
- ironic, relatable
- Language
- en
- Added