[PD-dev] porting MSP externals - sysmem_newptrclear and sysmem_freeptr

Martin Peach chakekatzil at gmail.com
Sun Jan 28 20:54:57 CET 2018


On Sun, Jan 28, 2018 at 11:47 AM, Ed Kelly via Pd-dev <pd-dev at lists.iem.at>
wrote:

> Hi Devs,
>
> I'm attempting to port a library of MSP externals for LPC analysis and
> resynthesis.
> I've come across these elements from the Max API:
>
> t_ptr
> <https://cycling74.com/sdk/max-sdk-7.3.3/html/group__misc.html#ga70766a030fcd392d4574fa59b296a68e>
>  sysmem_newptrclear
> <https://cycling74.com/sdk/max-sdk-7.3.3/html/group__memory.html#ga1c178a079247f715c6e34c828d375324>
> (long size)
> and
> void sysmem_freeptr
> <https://cycling74.com/sdk/max-sdk-7.3.3/html/group__memory.html#ga200c82639e547869db1f3887d17102d3>
> (void *ptr)
>
> My head has hit a block, and I need to learn about how Pd deals with these
> aspects of memory / pointer allocation.
> Do I need to just init a pointer in the code?
>

I guess you should use one or more of these functions from m_pd.h:

/* --------------- 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);

getzbytes is probably the same as sysmem_newptrclear, and freebytes will do
what sysmem_freeptr does.

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20180128/6a15f8ea/attachment.html>


More information about the Pd-dev mailing list