[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Question about memory under MagiC



On Sunday 23 Oct 2011 05:48:07 Lonny Pursell wrote:

> > I'm developing an accessory that I would like to be compatible with
> > MagiC. In this program there is a piece of code that writes a string
> > into a Mxalloc'ed buffer (a simple "strcpy(buffer, path);"). I'm 100%
> > confident both the source and destination (with space for the
> > terminating null) are the exact same size so this is not the problem and
> > indeed this works fine under MiNT with MP on.
> > 
> > However, under MagiC (tested by someone else) it crashes ("Memory block
> > destroyed by user program" message from MagiC).
> > 
> > So, out of curiosity, I tried with snprintf() and this works under MagiC!
> > Once again, I know for a fact both source and dest are equal sizes. Why
> > would MagiC accept snprintf() but crash with strcpy() when the
> > destination buffer is large enough for the string + terminating '\0'?
> > 
> > Are there known memory allocation differences between the two systems?

> Be sure to strip off the extra MP and ram type bits before passing values
> to mxalloc() in magic.  You would think it would ignore them, but no it
> makes magic at strange.

I'm simply doing "Mxalloc(size, MX_PREFTTRAM);" for MagiC. Do you mean to say 
that the MX_PREFTTRAM bit might be too much for MagiC?

Cheers,
JFL
-- 
Jean-François Lemaire