Re: Memory allocation?
Re: Memory allocation?
- Subject: Re: Memory allocation?
- From: Marc Poirier <email@hidden>
- Date: Mon, 20 Oct 2003 08:29:07 -0500 (CDT)
On Mon, 20 Oct 2003, Mark's Studio wrote:
>
Im not sure how to allocate memory for what i need.
>
>
>
float waveformSamples[32][512];
>
>
is this to big?
That's 64 MB. Which is pretty big, but I guess not "too" big by today's
standards. But definitely not something that you would want to just
allocate like that when declared, it will make your binary take a long
time to load, so doing it dynamically (as below) would be much preferred.
>
if i allocate the memory like this
>
>
waveformSamples = ( float* ) malloc (32 * 512 * sizeof ( float
>
) );
>
>
how do i declare waveformSamples,
>
so i can access it like waveformSamples[i][j]
const long kNumWaveforms = 32;
const long kWaveformSize = 512;
// allocate:
waveformSamples = (float**) malloc(kNumWaveforms * sizeof(float*));
for (int i=0; i < kNumWaveforms; i++)
waveformSamples[i] = (float*) malloc(kWaveformSize * sizeof(float));
// deallocate:
for (int i=0; i < kNumWaveforms; i++)
free(waveformSamples[i]);
free(waveformsSamples);
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.