This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using asprintf without memory leaks


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" --------
========================================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]