[PATCH 3/5] Convert dmxSetDefaultFontPath to use strdup instead of malloc+strncpy
Jeremy Huddleston
jeremyhu at apple.com
Sat Oct 29 00:29:26 PDT 2011
For all of them,
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
In this one, it looks like fp should be a (const char *) also. If you throw that in there in a followup patch, consider it r-b as well.
On Oct 28, 2011, at 21:41, Alan Coopersmith wrote:
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
> hw/dmx/dmxinit.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
> index b950c50..9a60bf3 100644
> --- a/hw/dmx/dmxinit.c
> +++ b/hw/dmx/dmxinit.c
> @@ -802,18 +802,15 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
> strcpy. */
> static void dmxSetDefaultFontPath(char *fp)
> {
> - int fplen = strlen(fp) + 1;
> -
> if (dmxFontPath) {
> - int len;
> + int fplen = strlen(fp) + 1;
> + int len = strlen(dmxFontPath);
>
> - len = strlen(dmxFontPath);
> dmxFontPath = realloc(dmxFontPath, len+fplen+1);
> dmxFontPath[len] = ',';
> strncpy(&dmxFontPath[len+1], fp, fplen);
> } else {
> - dmxFontPath = malloc(fplen);
> - strncpy(dmxFontPath, fp, fplen);
> + dmxFontPath = strdup(fp);
> }
>
> defaultFontPath = dmxFontPath;
> --
> 1.7.3.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list