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?
Maybe every platform should switch to use libloader at some point. > > 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 > -- o...@lunarg.com _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev