title: How do I mock memory allocation failures?
body: <p>I want to extensively test some pieces of C code for memory leaks.</p>
  
  <p>On my machine I have 4 Gb of RAM, so it's very unlikely for a dynamic memory allocation to fail. Still I want to see the comportment of the code if memory allocation fails, and see if the recover mechanism is "strong" enough.</p>
  
  <p>What do you suggest ? How do I emulate an environment with lower memory specs ? How do i mock my tests ?</p>
  
  <p><strong>EDIT</strong>:
  I want my tests to be code independent. I only have "access" to return values for different functions in the library I am testing. I am not supposed to write "test logic" inside the code I am testing.</p>