Re: [cc65] Config files and heap space

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-05-20 16:38:26
On Wed, May 20, 2009 at 09:10:13AM -0500, Dan Winslow wrote:

> The following function is intended to display a rough estimate of the amount
> of heap available at program startup :

Is there a reason not to use the _heapmaxavail / _heapmemavail functions
supplied by the library?

> ( I know its crude at best, and if there are better ways of doing this I'd
> be glad to hear of them, but this is not what I am asking about )

    #include <stdlib.h>
    #include <stdio.h>
    int main (void)
    {
        printf ("Available heap space:  %u\n", (unsigned) _heapmemavail ());
        printf ("Size of largest block: %u\n", (unsigned) _heapmaxavail ());
        return EXIT_SUCCESS;
    }

(untested, there may be typos).

> If the the config file I am using has the start address set at 2E00 (
> STARTADDRESS: default = $2E00; ), I get around 30k reported by the above
> function. If the config file I am using has the start address set at 2000 (
> which should be ok with the DOS I am using ), I get 0 k reported. The program
> seems to run fine either way..altough I am not using malloc in my code (yet).

That sounds as if this is an atari specific problem. Maybe Christian can
comment on it. There are some variables in _heap.h which have more information
about the heap. They may be helpful when diagnosing problems.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed May 20 16:40:25 2009

This archive was generated by hypermail 2.1.8 : 2009-05-20 16:40:27 CEST