gallium: don't use flexible array members in drivers for vertex elements cso
authorRoland Scheidegger <sroland@vmware.com>
Tue, 9 Mar 2010 13:23:00 +0000 (14:23 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 9 Mar 2010 13:23:00 +0000 (14:23 +0100)
While this c99 feature should work with most compilers, valgrind doesn't
really like it, and this only really saves some memory, we don't do this
in similar occasions (like the blend state) neither.

src/gallium/drivers/cell/ppu/cell_context.h
src/gallium/drivers/cell/ppu/cell_state_vertex.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i965/brw_pipe_vertex.c
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_vertex.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/softpipe/sp_state_vertex.c
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_vertex.c

index 84ad0f342200c0fa112048278b4ddd7c91872671..584f3558044098fa355f5411eb6e92b1eba59c96 100644 (file)
@@ -96,7 +96,7 @@ struct cell_buffer_list
 struct cell_velems_state
 {
    unsigned count;
-   struct pipe_vertex_element velem[];
+   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
 }
 
 /**
index 35c919fb6b7badb403b056141f99b174eb2a0129..d3efb8ecea21fce5f8e2add2a1e1d37ce26b0ed8 100644 (file)
@@ -43,7 +43,7 @@ cell_create_vertex_elements_state(struct pipe_context *pipe,
 {
    struct cell_velems_state *velems;
    assert(count <= PIPE_MAX_ATTRIBS);
-   velems = (struct cell_velems_state *) MALLOC(sizeof(struct cell_velems_state) + count * sizeof(*attribs));
+   velems = (struct cell_velems_state *) MALLOC(sizeof(struct cell_velems_state));
    if (velems) {
       velems->count = count;
       memcpy(velems->velem, attribs, sizeof(*attribs) * count);
index 369c63eeceb3ec1369bd19a6d9b05fb64725525e..3e383aaa1ca14cf0c30fbb2dc9f8e2a7dc12c361 100644 (file)
@@ -189,7 +189,7 @@ struct i915_sampler_state {
 
 struct i915_velems_state {
    unsigned count;
-   struct pipe_vertex_element velem[];
+   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
 };
 
 struct i915_texture {
index 46406065c370485db91e2f2a0bed37cbce033a44..8927dfc33d474177aeae2080b704399fefd119d5 100644 (file)
@@ -749,7 +749,7 @@ i915_create_vertex_elements_state(struct pipe_context *pipe,
 {
    struct i915_velems_state *velems;
    assert(count <= PIPE_MAX_ATTRIBS);
-   velems = (struct i915_velems_state *) MALLOC(sizeof(struct i915_velems_state) + count * sizeof(*attribs));
+   velems = (struct i915_velems_state *) MALLOC(sizeof(struct i915_velems_state));
    if (velems) {
       velems->count = count;
       memcpy(velems->velem, attribs, sizeof(*attribs) * count);
index 3d84fb86fb46e53dd24f55429771eb90d27ed7e1..d6a840857ec0fd7b20e853847ccc683e624b210c 100644 (file)
@@ -215,7 +215,7 @@ static void* brw_create_vertex_elements_state( struct pipe_context *pipe,
                                                const struct pipe_vertex_element *attribs )
 {
    /* note: for the brw_swtnl.c code (if ever we need draw fallback) we'd also need
-      store the original data */
+      to store the original data */
    struct brw_context *brw = brw_context(pipe);
    struct brw_vertex_element_packet *velems;
    assert(count <= BRW_VEP_MAX);
index 57f5bd004229fc2230cc821a13bfe9d91f016f2c..6dbdc195bfc3065f10ba3f95c94b6181d25c4fe5 100644 (file)
@@ -121,7 +121,7 @@ struct lp_vertex_shader {
 
 struct lp_velems_state {
    unsigned count;
-   struct pipe_vertex_element velem[];
+   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
 };
 
 
index 5a9b6d5e18c74f44aa7f784df560eca07136253b..2ddd110a5f9c292739fb22b963526fce15ea0bb4 100644 (file)
@@ -42,7 +42,7 @@ llvmpipe_create_vertex_elements_state(struct pipe_context *pipe,
 {
    struct lp_velems_state *velems;
    assert(count <= PIPE_MAX_ATTRIBS);
-   velems = (struct lp_velems_state *) MALLOC(sizeof(struct lp_velems_state) + count * sizeof(*attribs));
+   velems = (struct lp_velems_state *) MALLOC(sizeof(struct lp_velems_state));
    if (velems) {
       velems->count = count;
       memcpy(velems->velem, attribs, sizeof(*attribs) * count);
index a6b9a841fea2f4bae050d139c0a31cb968a77ba9..6b01c0f4d722b13a80b724d245a896850d8f175a 100644 (file)
@@ -102,7 +102,7 @@ struct sp_geometry_shader {
 
 struct sp_velems_state {
    unsigned count;
-   struct pipe_vertex_element velem[];
+   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
 };
 
 
index e7dc3d002bac18bda3003b78f24b74ac5650f5f6..a151758ddcad96c79f6144952e13f50401313f8b 100644 (file)
@@ -43,7 +43,7 @@ softpipe_create_vertex_elements_state(struct pipe_context *pipe,
 {
    struct sp_velems_state *velems;
    assert(count <= PIPE_MAX_ATTRIBS);
-   velems = (struct sp_velems_state *) MALLOC(sizeof(struct sp_velems_state) + count * sizeof(*attribs));
+   velems = (struct sp_velems_state *) MALLOC(sizeof(struct sp_velems_state));
    if (velems) {
       velems->count = count;
       memcpy(velems->velem, attribs, sizeof(*attribs) * count);
index 4d9f00991a715281aaa666fc3774857e7a05b6b8..791d30edc0ec85b30c84e52f9c51655f17e1a454 100644 (file)
@@ -171,7 +171,7 @@ struct svga_sampler_state {
 
 struct svga_velems_state {
    unsigned count;
-   struct pipe_vertex_element velem[];
+   struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
 };
 
 /* Use to calculate differences between state emitted to hardware and
index 979deb12afb3e3b74eee6af68bdf83c3f30847f0..d4a1280e74c75e541c8436c46c7125dd40384150 100644 (file)
@@ -73,7 +73,7 @@ svga_create_vertex_elements_state(struct pipe_context *pipe,
 {
    struct svga_velems_state *velems;
    assert(count <= PIPE_MAX_ATTRIBS);
-   velems = (struct svga_velems_state *) MALLOC(sizeof(struct svga_velems_state) + count * sizeof(*attribs));
+   velems = (struct svga_velems_state *) MALLOC(sizeof(struct svga_velems_state));
    if (velems) {
       velems->count = count;
       memcpy(velems->velem, attribs, sizeof(*attribs) * count);