I don't need to use the heap particularly. I didn't know I could do it on
the stack. That would be easier than having to loop through the first
dimension of the array to free up memory of the second dimension.

So would I just us alloca() in place of malloc or new?

- Dave

<May I ask why you need to allocate this on the heap?  If all you need is
<the ability to be dynamic, and you know your array won't exceed the
<stack size, you can use gcc's alloca() allocator to allocate stack
<memory dynamically.  I use alloca extensively when dealing with string
<operations, for example.  You don't ever have to free the memory; just
<return from the subroutine and it's all cleared off.  You obviously
<cannot return a string as a return value from a parameter that's been
<alloca'ted.


--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to