If the symbol kVariableLengthArray is a compile-time constant, this means that you can allocate a single buffer on the stack ("automatic" storage type, in C).
If the symbol kVariableLengthArray is a compile-time constant, this means that you can allocate a single buffer on the stack ("automatic" storage type, in C). AudioBufferList single; single. MNumberBuffers = 1; Since the struct includes a count, it also means that you can create an instance with any number of buffers, like so: AudioBufferList * get_n_buffers(size_t num) { AudioBufferList *list; if(num mBuffers0); list->mNumberBuffers = num; return list; } The latter code dynamically allocates an AudioBufferList, and relies on the fact that the array is last.So in memory, it will lookas if the AudioBuffer ends with the proper number of AudioBuffer instances, as the proper amount of space will be allocated.
Ahhhh, I see. Great, thanks. – hooleyhoop Apr 21 '10 at 11:16 Should that be 'malloc( sizeof(AudioBufferList) + (num-1)*sizeof( list->mBuffers0) );'?
Thanks for your patience. – hooleyhoop Apr 21 '10 at 13:52 @mustISignUp: no, I find it bad to repeat type names, and always prefer sizeof on expressions of the proper type. That way, if list were to change to a different pointer type, it would still do the rigtht thing.
Sizeof *list is exactly what I mean. – unwind Apr 21 '10 at 14:22 ok, thanks - point taken. – hooleyhoop Apr 21 '10 at 14:50 I absolutely believe you but can't grasp how 'sizeof *list' is enough memory for a struct AudioBufferList… – hooleyhoop Apr 21 '10 at 14:58.
AudioBuffer * mBuffers; You are declaring a pointer to AudioBuffer In such a case, you need to allocate enough memory, for instance with malloc(). Structures will be placed on the heap, and you will need to free the memory with free() after usage. AudioBuffer mBuffers 1 ; You are declaring an array of AudioBuffer.
Memory is allocated automatically on the stack. No need to call free. So when it's inside a structure, it's easier to work arrays, as you don't need to allocate memory explicitly to the structure member: AudioBufferList myBufferList; Otherwise, you would have to do: AudioBufferList myBufferList; myBufferList.
MBuffers = malloc( sizeof( AudioBuffer ) * kVariableLengthArray ); /* ... */ free( myBufferList. MBuffers ).
Sorry, I might be being stupid but I still don't get it. You're saying that 'AudioBuffer mBuffers kVariableLengthArray ' allocates memory for 1 AudioBuffer? – hooleyhoop Apr 21 '10 at 11:00 How is that a list?
– hooleyhoop Apr 21 '10 at 11:08 It's an array, with only one element. But as the number of elements comes from a constant, maybe it will change in a future release. So declaring it in such a way leaves the possibility to have more AudioBuffers.
– Macmade Apr 21 '10 at 11:13.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.