<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[In my C++ code, I make extensive use of STL containers to ensure I *never* have to dynamically allocate memory.]]></title><description><![CDATA[<p>In my C++ code, I make extensive use of STL containers to ensure I *never* have to dynamically allocate memory.  Works great.  Valgrind runs clean.  Need a single object, return it.  Need a bunch of objects, return a vector, map, set, etc.</p><p>This codebase is the opposite.  Everything is malloc() or new.  The code I'm looking at right now is a simple vector of strings.  The codebase does use std::vector.  But instead of std::vector&lt;std::string&gt; they define it as a *pointer* to std::vector&lt;char*&gt;.  Note even the vector itself is dynamically allocated.  So they malloc() the memory for the vector (!?) and then malloc() each string.</p><p>First thing I did was change malloc() to new and new[] across the codebase to ensure objects are created correctly.  That solved a bunch of crashes.</p><p>So much use of dynamic memory.  Half the codebase is spent allocating memory, freeing it, checking to see if a function returned a nullptr or a pointer to an empty container.</p><p>This whole thing needs to be re-written. <a href="https://mstdn.ca/tags/cpp" rel="tag">#<span>cpp</span></a></p>]]></description><link>https://board.circlewithadot.net/topic/4c624263-ac18-4623-9ed8-23328f48dae3/in-my-c-code-i-make-extensive-use-of-stl-containers-to-ensure-i-never-have-to-dynamically-allocate-memory.</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 06:09:08 GMT</lastBuildDate><atom:link href="https://board.circlewithadot.net/topic/4c624263-ac18-4623-9ed8-23328f48dae3.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 04 May 2026 20:53:28 GMT</pubDate><ttl>60</ttl></channel></rss>