summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2018-07-19 11:36:19 +0200
committerMichel Dänzer <michel@daenzer.net>2018-07-20 11:30:00 +0200
commitb8d8416792488f7b15c94234d7e0e35d5ce10ed9 (patch)
treed0c489c52d00caa4f20bbaf3ff2a3c409f410820
parentae8e02c6fc4ef5d5340b8cd4739e66b19b9e3386 (diff)
Free previous xf86CrtcRec gamma LUT memory
We were leaking it. Also, don't bother allocating new memory if it's already the expected size. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/drmmode_display.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 2222022..e127593 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -3649,13 +3649,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;