vc4: Fix leak of simulator memory on screen cleanup.
authorEric Anholt <eric@anholt.net>
Sun, 14 Dec 2014 00:40:54 +0000 (16:40 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 15 Dec 2014 07:11:59 +0000 (23:11 -0800)
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/drivers/vc4/vc4_simulator.c

index 18451bd71a77d87e802785a38eca71231f8ea1a2..7a1840aaf4c8265159201d0b6cb2caefccaeff5a 100644 (file)
@@ -30,6 +30,7 @@
 #include "util/u_debug.h"
 #include "util/u_memory.h"
 #include "util/u_format.h"
+#include "util/ralloc.h"
 
 #include "vc4_screen.h"
 #include "vc4_context.h"
@@ -75,7 +76,7 @@ vc4_screen_get_vendor(struct pipe_screen *pscreen)
 static void
 vc4_screen_destroy(struct pipe_screen *pscreen)
 {
-        free(pscreen);
+        ralloc_free(pscreen);
 }
 
 static int
@@ -402,7 +403,7 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen,
 struct pipe_screen *
 vc4_screen_create(int fd)
 {
-        struct vc4_screen *screen = CALLOC_STRUCT(vc4_screen);
+        struct vc4_screen *screen = ralloc(NULL, struct vc4_screen);
         struct pipe_screen *pscreen;
 
         pscreen = &screen->base;
index bb4a669e8f57261ccb06cc5436d2d896b47b4464..ee4ad96123b98c0b9d56979df6a61df04a27cb38 100644 (file)
@@ -24,6 +24,7 @@
 #ifdef USE_VC4_SIMULATOR
 
 #include "util/u_memory.h"
+#include "util/ralloc.h"
 
 #include "vc4_screen.h"
 #include "vc4_context.h"
@@ -191,7 +192,8 @@ void
 vc4_simulator_init(struct vc4_screen *screen)
 {
         screen->simulator_mem_size = 256 * 1024 * 1024;
-        screen->simulator_mem_base = malloc(screen->simulator_mem_size);
+        screen->simulator_mem_base = ralloc_size(screen,
+                                                 screen->simulator_mem_size);
 
         /* We supply our own memory so that we can have more aperture
          * available (256MB instead of simpenrose's default 64MB).