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

Re: [MiNT] MiNTlibs question



Hi!

On Sat, Apr 24, 1999 at 11:19:48PM +0000, Jo Even Skarstein wrote:
> Does anybody know if any of the memory-allocation functions
> in MiNTlibs (malloc, calloc) allocates space on the stack?
> I'm currently working on the pilot-link libs and tools, most
> of these needs a monster-stack (~1Mb) to work correctly.
> 
> I've moved some char-buffers from the stack to the heap, but
> there are still some functions that obviously use huge amounts
> of stack. All of these calloc's buffers, so I assume that calloc
> is the problem here.

calloc() is implemented as a malloc() with a subsequent bzero of the
memory block.

Possible reasons:  You have changed _stksize to a negative value (see the
comments in crtinit.c) or your code redefines calloc() so that it really
uses alloca instead.

Or:  There is an undocumented function

	extern void _mallocChunkSize (size_t newsize);

which changes the chunk size to ask the OS for (via Malloc resp. Mxalloc)
from 4096 to NEWSIZE.  I'm not familiar with the code, try it out (and
please let me know if you find out something interesting).

A little more (vague) information:  There are two static variables MAXHUNK
and MINHUNK which denote the maximum (default 32k) and minimum (4k) size
of memory chunks to Malloc.  Calling _mallocChunkSize will change _both_
variables!  And the source code states in a comment that choosing too
large a default value will cause stack/heap clashes on 1 MB machines.

Hope this helps.

Ciao

Guido
-- 
http://stud.uni-sb.de/~gufl0000
mailto:gufl0000@stud.uni-sb.de