On Fri, Apr 9, 2010 at 5:56 PM, Peter Wehrfritz <[email protected]> wrote: > Gustavo Sverzut Barbieri wrote: >> >> Please check the -Wall -Wextra errors! U must check the return of >> asprintf() variants.... And then you can use the optimized >> append/insert that does not need to strlen() >> > > Or you get the size first with snprintf(NULL, 0 ...) and than write it with > snprintf() directly into the buffer, this saves you one allocation. In the > case of append you can > even fill the yet unused bytes of the buffer with snprintf() first, in some > cases the buffer might be large enough so you don't need a following buffer > resize and a second snprintf. The nice side effect is that you don't rely on > gnu extensions.
one could do that if asprintf() is not available. AFAIK it is on BSD as well, and Vincent said about supporting it with Evil for windows. As for reference, seems that what you suggested will not work on windows since their snprint() does not return the number of required characters... then you need to do that to fprintf() to /dev/null (windows version). To summarize it: - asprintf is nice and should be used wherever possible. - double snprintf is an alternative, but will not be portable as well - fprintf to a discard device should work, but is likely to be slower. -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: [email protected] Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
