> That’s really all there is to it. Conceptually, C array declarations are a > twofer: shorthand for a pointer and the stack memory it points to. > Conceptually, once declared, an array variable is just a pointer.
Right... But I guess what's not clear to me is, when does one use malloc over the stack version? Is it only when you have a stack overflow? Or is there some magic number of elements that fall under a best-practice-use-malloc rule? My program is going to be operating often over batches of 25ms frames of samples at 8khz, so that's 200 samples in a given buffer. Is that something that should be on the heap or stack? Speaking of heaps and stacks, I was having a conversation in IRC a few days ago where a c "expert" was arguing that there is no such thing as a heap or stack in C.... Sent from my iPhone On Mar 3, 2015, at 10:45 AM, Quincey Morris <[email protected]> wrote: > On Mar 3, 2015, at 00:47 , Patrick J. Collins <[email protected]> > wrote: >> >> So, I guess this goes along with my confusion about arrays and pointers... > > You know what this means: > >> float *coefficients = malloc (n * sizeof (float)); > > > Details aside, it means: > >> float *coefficients = pointer to a block of memory on the heap > > > Now this: > >> float coefficients [11]; > > > means: > >> float *coefficients = pointer to a block of memory on the stack > > > That’s really all there is to it. Conceptually, C array declarations are a > twofer: shorthand for a pointer and the stack memory it points to. > Conceptually, once declared, an array variable is just a pointer. > > (That’s the concept. The underlying implementation is a bit more subtle.) > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Objc-language mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/objc-language/patrick%40collinatorstudios.com > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com This email sent to [email protected]
