#### 4.1.3 Memory Allocation ¶

    void *fftw_malloc(size_t n);
    void fftw_free(void *p);

These are functions that behave identically to `malloc` and `free`, except that they guarantee that the returned pointer obeys any special alignment restrictions imposed by any algorithm in FFTW (e.g. for SIMD acceleration). See SIMD alignment and fftw_malloc.

Data allocated by `fftw_malloc` must be deallocated by `fftw_free` and not by the ordinary `free`.

These routines simply call through to your operating system’s `malloc` or, if necessary, its aligned equivalent (e.g. `memalign`), so you normally need not worry about any significant time or space overhead. You are not required to use them to allocate your data, but we strongly recommend it.

Note: in C++, just as with ordinary `malloc`, you must typecast the output of `fftw_malloc` to whatever pointer type you are allocating.

We also provide the following two convenience functions to allocate real and complex arrays with `n` elements, which are equivalent to `(double *) fftw_malloc(sizeof(double) * n)` and `(fftw_complex *) fftw_malloc(sizeof(fftw_complex) * n)`, respectively:

    double *fftw_alloc_real(size_t n);
    fftw_complex *fftw_alloc_complex(size_t n);

The equivalent functions in other precisions allocate arrays of `n` elements in that precision, e.g. `fftwf_alloc_real(n)` is equivalent to `(float *) fftwf_malloc(sizeof(float) * n)`.