title: Which print calls in C do NOT ever call malloc() under the hood?
body: <p>I'm implementing my own <code>fast_malloc()</code> to replace <code>malloc()</code>. I need debugging prints inside it. Are there any print calls which are guaranteed to NOT ever call <code>malloc()</code>, or do I need to create my own, safe versions?</p>
  <p>Previously, <a href="https://stackoverflow.com/questions/68188903/segmentation-fault-core-dumped-for-no-such-file-or-directory-for-libiop-h">I had accidentally caused infinite recursion by having my <code>malloc()</code> call <code>printf()</code>, which then calls <code>malloc()</code>, which then calls <code>printf()</code>...forever.</a></p>
  <p>If I need to create my own safe versions which use a fixed-size static array under the hood as the buffer to format into, that's all I need to know. I can do that.</p>
  <p>How about <code>puts()</code> or <code>putc()</code>? They should be safe, no?</p>
  <p>I'm on Linux Ubuntu 20.04. Ideally, whatever I do will be cross-platform-compliant, but I suppose I can customize if I need to for low-level system calls.</p>
  <hr />
  <h2>Related:</h2>
  <ol>
  <li>Related, but not a duplicate since it is specific to <code>snprintf()</code>: <a href="https://stackoverflow.com/questions/6803808/snprintf-that-calls-malloc-or-snprintf-that-does-not-call-malloc">snprintf that calls malloc, or snprintf that does not call malloc</a></li>
  <li><a href="https://stackoverflow.com/questions/6743034/does-fprintf-use-malloc-under-the-hood">Does fprintf use malloc() under the hood?</a></li>
  </ol>