[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Question about memory under MagiC
on 10/22/11 5:06 PM, Jean-François Lemaire wrote:
> Hi,
>
> Sorry for this off-topic question but I'm bewildered by a problem that doesn't
> make sense to me.
>
> 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?
>
> Thanks in advance for any info anyone might have.
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.
--
Lonny Pursell http://www.bright.net/~gfabasic/