Jeff King <p...@peff.net> writes: > On Wed, Jun 18, 2014 at 03:32:08PM -0700, Junio C Hamano wrote: > >> > str = xstrdup_fmt(fmt, some, args); >> > --- >> > I'm open to suggestions on the name. This really is the same thing >> > conceptually as the GNU asprintf(), but the interface is different (that >> > function takes a pointer-to-pointer as an out-parameter, and returns the >> > number of characters return). >> >> Naming it with anything "dup" certainly feels wrong. The returned >> string is not a duplicate of anything. > > I was somewhat inspired by "mkpathdup" and friends.
That name is from "mkpath gives its result in a static buffer and forces the callers to xstrdup() if they want to keep the result; this is a thin wrapper to do so for the caller". As there is no str_fmt() that gives its result in a static, so... > I considered that, but I do find asprintf's interface unnecessarily > annoying... Yes, it is annoying. > Would it be crazy to just call it xprintf? By our current scheme that > would be "a wrapper for printf", which means it is potentially > confusing. > > Literally any other unused letter would be fine. dprintf for detach? I > dunno. If we twist the logic behind the 'mkpathdup' name a little bit, perhaps we can call it sprintf_dup or something. That is, "sprintf wants a fixed preallocated piece of memory to print into, and we relieve the callers of having to do so", perhaps? dprintf, mprintf, etc. are also fine by me. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html