Skip to contentSkip to conversation

Free previous xf86CrtcRec gamma LUT memory

PATCH In review Michel Dänzer 2 participants 2 messages Jul 19, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Free previous xf86CrtcRec gamma LUT memory

From: Michel Dänzer <[email protected]>

We were leaking it.

Also, don't bother allocating new memory if it's already the expected size.

---
 src/drmmode_display.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/drmmode_display.c +6 -1
index 1aefd199b..e947ca979 100644
@@ -3629,13 +3629,18 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 
 			for (i = 0; i < xf86_config->num_crtc; i++) {
 				xf86CrtcPtr crtc = xf86_config->crtc[i];
-				void *gamma = malloc(1024 * 3 * sizeof(CARD16));
+				void *gamma;
 
+				if (crtc->gamma_size == 1024)
+					continue;
+
+				gamma = malloc(1024 * 3 * sizeof(CARD16));
 				if (!gamma) {
 					ErrorF("Failed to allocate gamma LUT memory\n");
 					return FALSE;
 				}
 
+				free(crtc->gamma_red);
 				crtc->gamma_size = 1024;
 				crtc->gamma_red = gamma;
 				crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
Signature · 6 lines
2.18.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180719093711.16417-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 8 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

We were leaking it.

Also, don't bother allocating new memory if it's already the expected size.

Quoted 31 lines
---
 src/drmmode_display.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/drmmode_display.c +6 -2
index 1aefd199b..e947ca979 100644
@@ -3629,13 +3629,18 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 
                        for (i = 0; i < xf86_config->num_crtc; i++) {
                                xf86CrtcPtr crtc = xf86_config->crtc[i];
-                               void *gamma = malloc(1024 * 3 * sizeof(CARD16));
+                               void *gamma;
 
+                               if (crtc->gamma_size == 1024)
+                                       continue;
+
+                               gamma = malloc(1024 * 3 * sizeof(CARD16));
                                if (!gamma) {
                                        ErrorF("Failed to allocate gamma LUT memory\n");
                                        return FALSE;
                                }
 
+                               free(crtc->gamma_red);
                                crtc->gamma_size = 1024;
                                crtc->gamma_red = gamma;
                                crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
--

2.18.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx