z88dk forums

z80 Development Kit

You are not logged in.

#1 2019-09-21 17:38:45

alank2
Member
Registered: 2017-03-01
Posts: 44

Is there a coreleft() function in alloc.h?

Is there a coreleft() function in alloc.h?  or something similar?  I'd like to see how much memory is available when loading a CP/M program.

Offline

 

#2 2019-09-21 23:09:54

dom
Administrator
Registered: 2007-07-15
Posts: 1453
Website

Re: Is there a coreleft() function in alloc.h?

There's mallinfo() which should give you the space remaining and the largest available chunk.

Offline

 

#3 2019-09-21 23:48:11

alank2
Member
Registered: 2017-03-01
Posts: 44

Re: Is there a coreleft() function in alloc.h?

Thanks, I am trying:

Code:

#include <stdio.h>
#include <stdarg.h>
#include <alloc.h>

int main()
  {
    unsigned int total,largest;

    mallinfo(&total,&largest);

    printf("%u %u\n",total,largest);

    return 0;
  }

main.c:9: warning 112: function 'mallinfo' implicit declaration
main.c:9: error 101: too many parameters

Offline

 

#4 2019-09-22 00:47:07

dom
Administrator
Registered: 2007-07-15
Posts: 1453
Website

Re: Is there a coreleft() function in alloc.h?

Ah. I didn't realise you were using newlib. It looks like you can use heap_info(_malloc_heap, <callback_function>) and walk the blocks to determine usage.

Given your other problem (fopen not working), it's probably worth switching to classic (drop the -clib= option) to get the features you want.

Originally, the classic library and new library were completely different code bases, however over time they have converged with the result that the only differences are as follows:

* Classic supports many more targets and has different way of implementing the crt0 startup file
* <stdio.h> is a different implementation that supports file io
* Classic supports multiple floating point libraries for pure sccz80 compilations
* Classic provides the cross platform libraries detailed below
* Classic tends to be tuned at link time, newlib at library build time

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson