Using asprintf without memory leaks

Ian Pilcher arequipeno@gmail.com
Thu Nov 26 22:21:00 GMT 2015


asprintf(3) says:

   When successful, these functions return the number of bytes printed,
   just like sprintf(3).  If memory allocation wasn't possible, or some
   other error occurs, these functions will return -1, and the contents
   of strp is undefined.

If -1 is returned, can I at least assume that any memory that was
allocated has been freed?  If not, it's hard to see how asprintf can
be used without risking memory leaks.

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================



More information about the Libc-help mailing list