[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::atarist

Title:Atari ST, TT, & Falcon
Notice:Please read note 1.0 and its replies before posting!
Moderator:FUNYET::ANDERSON
Created:Mon Apr 04 1988
Last Modified:Tue May 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1433
Total number of notes:10312

303.0. "Buggy Laser C malloc()??" by CADSYS::DALTON () Wed Nov 16 1988 16:42

	Has anyone run into (or heard of) bugs in the Laser C malloc()
routine? I've had problems using it lately because it appears to be giving me
memory that it's already allocated to another block... I compiled the code
with the Lattice compiler and it ran fine. I need to use Laser because of it's
in-line assembly, though.
T.RTitleUserPersonal
Name
DateLines
303.1Blame AtariACE::SANDERSa belaganaThu Nov 17 1988 00:4810
        Its not Laser C, it is the malloc() in the Atari OS.  It
        allocates an extra 64 bytes (if memory serves).
        
        TOS V1.4, if it ever gets released, will have a work around for
        this according the the folks at Atari, however malloc() will
        function exactly the same, according to the last public decision
        posted on the usenet.
        
        Bob
303.2When is a Malloc() not a malloc()?LEDDEV::WALLACEThu Nov 17 1988 15:0728
    I don't use Laser C so I can't answer your question specificly,
    but...
    
    You may want to try one of the PD malloc() routines that are around
    I've put the malloc() (and associated routines) from Mark Johnsons
    public domain C compiler (V2.0) in:
    		LEDDEV::DISK$USER9:[WALLACE.PUBLIC.ST]MALLOC.C
    
    This file includes malloc(), realloc(), calloc() and free(). It
    gets around the TOS Malloc() bug that I've heard about by calling
    Malloc() infrequently (which is possible since it asks for large
    chunks and manages the memory itself).
    
    The code looks like it should work with any C compiler (it doesn't
    use int's only long's and shorts' etc..). The one line you may have
    to change and/or modify is the trap(1,...) call thats used to access
    TOS's Malloc(). Mark Williams C I think has bios() calls as apposed
    to trap() calls and also defines Malloc() for you, I don't know
    how Laser C (or others) provide this interface but it should be
    an easy change.
    
    NOTE that Malloc() and malloc() are not the same! Malloc() is the
    TOS (or rom) memory allocator and malloc() is memory allocator library
    routine provided by your C compiler. It is possible that Laser C
    just defines malloc() to be equivelent to Malloc() and therefore
    is susceptable to Malloc()'s inherent bugs.
    
    	Ray
303.3I'll give MJC a whirlCADSYS::DALTONThu Nov 17 1988 16:429
	I was aware that malloc() is different from Malloc(). I tried
    using both and got similar results so that is most probably the
    root of the problem. I was considering just going ahead and writing
    my own but since the MJC routines are around I'll check them out 
    first. Thanks for making them available.

	Kent