Order of the Butterfly
Posts: 171 from 2006/10/6
From: Spain
Hi.
I found that any example of ASL library produces memory leaks when AslRequest() is called, maybe is my fault, but I have tried different examples, and all have the same problem, using MUI asl functions produces the same behaviour.
This is one example found on the web:
Code:
;/* filereq.c - Execute me to compile me with SASC 5.10
LC -b1 -cfistq -v -y -j73 filereq.c
Blink FROM LIB:c.o,filereq.o TO filereq LIBRARY LIB:LC.lib,LIB:Amiga.lib
quit
*/
#include <exec/types.h>
#include <exec/libraries.h>
#include <libraries/asl.h>
#include <clib/exec_protos.h>
#include <clib/asl_protos.h>
#include <stdio.h>
#ifdef LATTICE
int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
void chkabort(void) { return; } /* really */
#endif
UBYTE *vers = "$VER: filereq 37.0";
#define MYLEFTEDGE 0
#define MYTOPEDGE 0
#define MYWIDTH 320
#define MYHEIGHT 400
struct Library *AslBase = NULL;
struct TagItem frtags[] =
{
ASL_Hail, (ULONG)"The Amiga file requester",
ASL_Height, MYHEIGHT,
ASL_Width, MYWIDTH,
ASL_LeftEdge, MYLEFTEDGE,
ASL_TopEdge, MYTOPEDGE,
ASL_OKText, (ULONG)"O KAY",
ASL_CancelText, (ULONG)"not OK",
ASL_File, (ULONG)"asl.library",
ASL_Dir, (ULONG)"libs:",
TAG_DONE
};
void main(int argc, char **argv)
{
struct FileRequester *fr;
if (AslBase = OpenLibrary("asl.library", 37L))
{
if (fr = (struct FileRequester *)
AllocAslRequest(ASL_FileRequest, frtags))
{
if (AslRequest(fr, NULL))
{
printf("PATH=%s FILE=%sn", fr->rf_Dir, fr->rf_File);
printf("To combine the path and filename, copy the pathn");
printf("to a buffer, add the filename with Dos AddPart().n");
}
FreeAslRequest(fr);
}
else printf("User Cancelledn");
CloseLibrary(AslBase);
}
}
Every time that this program is executed, the system memory doesn't recovers at all, every execution leaves less memory. Is this the normal behaviour?
Here is the source and the executable file compiled with latest SDK and gcc 4.4.5.
aslreq.lhaBalrog Software -
AmigaSkool.netMac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
Amiga 1200D - OS 3.9 - Blizzard 603e/240mh