[Mesa-dev] [PATCH] ralloc: Add new [v]asprintf_rewrite_tail functions.

Eugeni Dodonov eugeni at dodonov.net
Wed Oct 26 09:30:14 PDT 2011


On Tue, Oct 25, 2011 at 00:33, Kenneth Graunke <kenneth at whitecape.org>wrote:

> This can be useful if you want to create a bunch of temporary strings
> with a common prefix.  For example, when iterating over uniform
> structure fields, one might want to create temporary strings like
> "pallete.primary", "palette.outline", and "pallette.shadow".
>
> This could be done by overwriting the '.' with a null-byte and calling
> ralloc_asprintf_append, but that incurs the cost of strlen("pallete")
> every time...when this is already known.
>
> These new functions allow you rewrite the tail of the string, given a
> starting index.  If the starting index is the length of the string, this
> is equivalent to appending.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>

Looks useful, and removal of extra strlen is nice bonus.

Reviewed-By: Eugeni Dodonov <eugeni.dodonov at intel.com>

-- 
Eugeni Dodonov
<http://eugeni.dodonov.net/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111026/98b1f663/attachment.htm>


More information about the mesa-dev mailing list