[PD-dev] Allocating memory in externals

Charles Henry czhenry at gmail.com
Fri Nov 9 01:44:25 CET 2007


Hi, Mike,
  There are a few Pd-specific calls, although there is no harm AFAICT
(I have used them before, but I am not an expert) with using malloc(),
calloc(), or alloca().  In m_pd.h (v. 0.40.2 for example), you will
find:
/* --------------- memory management -------------------- */
EXTERN void *getbytes(size_t nbytes);
EXTERN void *getzbytes(size_t nbytes);
EXTERN void *copybytes(void *src, size_t nbytes);
EXTERN void freebytes(void *x, size_t nbytes);
EXTERN void *resizebytes(void *x, size_t oldsize, size_t newsize);

for the pd-specific memory calls.

Chuck

On Nov 8, 2007 6:27 PM, Mike McGonagle <mjmogo at gmail.com> wrote:
> Hello all,
>
> I was wondering if there are any guidelines to allocating memory in an
> external? Is there any harm to using malloc/free? Or is there some
> PD-specific calls that should be used?
>
>
> Mike M
>
>
> --
> Help the Environment, Plant a Bush back in Texas!
>
> "I place economy among the first and most important republican
> virtues, and public debt as the greatest of the dangers to be feared.
> To preserve our independence, we must not let our rulers load us with
> perpetual debt."
> -- Thomas Jefferson, third US president, architect and author (1743-1826)
>
> "Give Peace a Chance" -- John Lennon (9 October 1940 – 8 December 1980)
>
> Peace may sound simple—one beautiful word— but it requires everything
> we have, every quality, every strength, every dream, every high ideal.
> —Yehudi Menuhin (1916–1999), musician
>
> If you think you can, or you think you can't, you are probably right.
> —Mark Twain
>
> "Art may imitate life, but life imitates TV."
> Ani DiFranco
>
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.at
> http://lists.puredata.info/listinfo/pd-dev
>




More information about the Pd-dev mailing list