[Mesa-dev] [PATCH 11/34] glsl: support compilation of geometry shaders

Kenneth Graunke kenneth at whitecape.org
Wed Jul 31 20:41:28 PDT 2013


On 07/31/2013 05:16 PM, Ian Romanick wrote:
> On 07/30/2013 03:16 PM, Kenneth Graunke wrote:
>> This code is getting ugly.  It looks like the idea is to allocate two
>> (now three) separate arrays, but somebody decided to be "clever" and
>> batch them into a single calloc/free big enough to hold all of them.
>
> Yeah, that was me.  Since way back, I hate dipping into malloc/free for
> a bunch of small, short-lived allocations.  What I really want to use is
> alloca, but alas.

In C++ you can just do:

struct gl_shader *vert_shader_list[prog->NumShaders];

which basically does alloca() as far as I can tell.  The problem is, any 
out of bounds writes smash the stack, and can't be caught by tools like 
Valgrind.

--Ken


More information about the mesa-dev mailing list