On 31 July 2013 20:41, Kenneth Graunke <kenn...@whitecape.org> wrote:
> 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 > Actually that's a C99 feature ("variable length arrays"), although GCC allows it as a C++ extension (try compiling with "-pedantic" and you'll get a warning). As far as I can tell from some internet research, MSVC doesn't support the feature at all, so unfortunately we can't use it in core mesa.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev