[Insight-developers] Using alloca

Matt McCormick matt.mccormick at kitware.com
Tue Mar 12 13:18:51 EDT 2013


Hi Brad,

For what its worth, it looks like the Chromium projects has a cool way
to create a container that uses the stack for a limited amount of
space:

  http://stackoverflow.com/questions/354442/looking-for-c-stl-like-vector-class-but-using-stack-
storage

HTH,
Matt

On Tue, Mar 12, 2013 at 4:10 PM, Bradley Lowekamp
<blowekamp at mail.nih.gov> wrote:
> Sean,
>
> I know what you mean about not wanting to to add something new like this. I have a patch in gerrit where I try to use it here:
>
>
> http://review.source.kitware.com/#/c/10209/1/Modules/Core/Common/src/itkImageRegionSplitterMultidimensional.cxx
>
> And the Windows compilers generated errors:
>
> http://open.cdash.org/viewBuildError.php?buildid=2840629
>
> So it does not appear to be compatible with VS 2008.
>
>
> For just this one patch I am not sure if it is worth it as well. Where this may also be quite useful in with the VectorImage's VariableLength pixel type. The needed malloc for the temporaries is undesirable and in multi-threaded code is a bit of a bottle neck. I think this may be a very useful tool for tight loops in those situations too, but I have not looked into it.
>
> Brad
>
>
> On Mar 12, 2013, at 11:59 AM, Sean McBride <sean at rogue-research.com> wrote:
>
>> On Tue, 12 Mar 2013 08:54:43 -0400, Bradley Lowekamp said:
>>
>>> I am thinking about using the "alloca" function in some code I'm working
>>> on for ITK, and wonder what other people think of it or others experience...
>>>
>>> From the BSD Library Functions Manual:
>>>
>>> DESCRIPTION
>>>    The alloca() macro allocates size bytes of space in the stack frame
>>> of the caller.  This temporary space is automatically freed on return.
>>>
>>> I am planning on using it for some dimension sized array in compiled
>>> templateless code, in lieu of C99 dynamic stack based arrays.
>>
>> Given that ITK has no use of alloca() currently, I'd be loathe to add it, personally.
>>
>> Does ITK currently use C99 VLAs anywhere?  If so, that would be a precedent, and I'd stick with that.
>>
>> Cheers,
>>
>> --
>> ____________________________________________________________
>> Sean McBride, B. Eng                 sean at rogue-research.com
>> Rogue Research                        www.rogue-research.com
>> Mac Software Developer              Montréal, Québec, Canada
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers


More information about the Insight-developers mailing list