On 02/06/14 07:31, Chia-I Wu wrote: > On Sun, Jun 1, 2014 at 11:53 PM, Emil Velikov <emil.l.veli...@gmail.com> > wrote: >> Originally all hardware drivers duplicate the driver_name string >> from an external source, while for the software rasterizer we set >> it to "swrast". Follow the example set by hw drivers this way >> we can free the string at dri2_terminate(). > Sounds fine to me. But from a quick look, platform_drm gets the > driver name from gbm, without strdup() on it. Does that need a > similar treatment too? > Seems like it, I've only tested egl+x11.
> Maybe every platform should switch to use libloader at some point. > Perhaps, I would rather keep out of it for the time being :) AFAICS platform_drm reuses most(all?) of gbm's properties, making sure things are in sync - one less thing for us to think about. -Emil > >> >> v2: Use strdup over strndup. Suggested by Ilia Mirkin. >> >> Cc: Chia-I Wu <o...@lunarg.com> >> Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> >> --- >> >> Normally I prefer strn* functions, although in this case looks ugly. >> >> Thanks for the suggestion Ilia. >> -Emil >> >> src/egl/drivers/dri2/egl_dri2.c | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/src/egl/drivers/dri2/egl_dri2.c >> b/src/egl/drivers/dri2/egl_dri2.c >> index c1497b8..f10afed 100644 >> --- a/src/egl/drivers/dri2/egl_dri2.c >> +++ b/src/egl/drivers/dri2/egl_dri2.c >> @@ -469,7 +469,11 @@ dri2_load_driver_swrast(_EGLDisplay *disp) >> struct dri2_egl_display *dri2_dpy = disp->DriverData; >> const __DRIextension **extensions; >> >> - dri2_dpy->driver_name = "swrast"; >> + /* >> + * Every hardware driver_name is set using strndup. Doing the same in >> + * here will allow is to simply free the memory at dri2_terminate(). >> + */ >> + dri2_dpy->driver_name = strdup("swrast"); >> extensions = dri2_open_driver(disp); >> >> if (!extensions) >> @@ -673,6 +677,7 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp) >> if (dri2_dpy->driver) >> dlclose(dri2_dpy->driver); >> free(dri2_dpy->device_name); >> + free(dri2_dpy->driver_name); >> >> switch (disp->Platform) { >> #ifdef HAVE_X11_PLATFORM >> -- >> 1.9.3 >> > > > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev