llvmpipe: use align_malloc for all structs containing ALIGN16 members
authorKeith Whitwell <keithw@vmware.com>
Tue, 18 Aug 2009 19:25:37 +0000 (20:25 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sat, 29 Aug 2009 08:21:34 +0000 (09:21 +0100)
Unless the struct is allocated aligned, aligning the members isn't very
helpful.

src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_quad_fs.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_tile_cache.c

index 66d0cf7..7e7015d 100644 (file)
@@ -106,7 +106,7 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
       }
    }
 
-   FREE( llvmpipe );
+   align_free( llvmpipe );
 }
 
 static unsigned int
@@ -143,11 +143,17 @@ llvmpipe_is_buffer_referenced( struct pipe_context *pipe,
 struct pipe_context *
 llvmpipe_create( struct pipe_screen *screen )
 {
-   struct llvmpipe_context *llvmpipe = CALLOC_STRUCT(llvmpipe_context);
+   struct llvmpipe_context *llvmpipe;
    uint i;
 
+   llvmpipe = align_malloc(sizeof(struct llvmpipe_context), 16);
+   if (!llvmpipe)
+      return NULL;
+
    util_init_math();
 
+   memset(llvmpipe, 0, sizeof *llvmpipe);
+
    llvmpipe->pipe.winsys = screen->winsys;
    llvmpipe->pipe.screen = screen;
    llvmpipe->pipe.destroy = llvmpipe_destroy;
index 1c44031..5a4cadc 100644 (file)
@@ -237,7 +237,7 @@ shade_begin(struct quad_stage *qs)
 static void
 shade_destroy(struct quad_stage *qs)
 {
-   FREE( qs );
+   align_free( qs );
 }
 
 
@@ -246,10 +246,12 @@ lp_quad_shade_stage( struct llvmpipe_context *llvmpipe )
 {
    struct quad_shade_stage *qss;
 
-   qss = CALLOC_STRUCT(quad_shade_stage);
+   qss = align_malloc(sizeof(struct quad_shade_stage), 16);
    if (!qss)
       return NULL;
 
+   memset(qss, 0, sizeof *qss);
+
    qss->stage.llvmpipe = llvmpipe;
    qss->stage.begin = shade_begin;
    qss->stage.run = shade_quads;
index 04ae644..f06538c 100644 (file)
@@ -1358,7 +1358,7 @@ void setup_prepare( struct setup_context *setup )
 
 void setup_destroy_context( struct setup_context *setup )
 {
-   FREE( setup );
+   align_free( setup );
 }
 
 
@@ -1367,9 +1367,14 @@ void setup_destroy_context( struct setup_context *setup )
  */
 struct setup_context *setup_create_context( struct llvmpipe_context *llvmpipe )
 {
-   struct setup_context *setup = CALLOC_STRUCT(setup_context);
+   struct setup_context *setup;
    unsigned i;
 
+   setup = align_malloc(sizeof(struct setup_context), 16);
+   if (!setup)
+      return NULL;
+
+   memset(setup, 0, sizeof *setup);
    setup->llvmpipe = llvmpipe;
 
    for (i = 0; i < MAX_QUADS; i++) {
index 94908f6..e2fb157 100644 (file)
@@ -88,8 +88,9 @@ lp_create_tile_cache( struct pipe_screen *screen )
    struct llvmpipe_tile_cache *tc;
    uint pos;
 
-   tc = CALLOC_STRUCT( llvmpipe_tile_cache );
+   tc = align_malloc( sizeof(struct llvmpipe_tile_cache), 16 );
    if (tc) {
+      memset(tc, 0, sizeof *tc);
       tc->screen = screen;
       for (pos = 0; pos < NUM_ENTRIES; pos++) {
          tc->entries[pos].addr.bits.invalid = 1;
@@ -118,7 +119,7 @@ lp_destroy_tile_cache(struct llvmpipe_tile_cache *tc)
       screen->tex_transfer_destroy(tc->tex_trans);
    }
 
-   FREE( tc );
+   align_free( tc );
 }