AminetAminet
Search:
84799 packages online
About
Recent
Browse
Search
Upload
Setup
Services

dev/c/rtlibrary.lha

Mirror:Random
Showing: m68k-amigaos iconppc-amigaos iconppc-morphos iconi386-aros iconi386-amithlon iconppc-warpup iconppc-powerup icongeneric icon
No screenshot available
Short:A kind of \"resource tracking\" makes cleanup easier.
Author:"Tomi Ollila" too at cs.hut.fi
Uploader:too cs hut fi
Type:dev/c
Architecture:m68k-amigaos
Date:1995-02-02
Download:dev/c/rtlibrary.lha - View contents
Readme:dev/c/rtlibrary.readme
Downloads:670

This library is public domain. Use it any way you want. I do :)
No warranty of any kind is given.

Rt library provides a way to "remember" what resources has been allocated 
for the task a program is doing. Then, at the end of program execution, one
`delete' -call will go through a stack of allocated stuff and call their
corresponding deallocation functions.

The initial and final procedures one must do are quite simple:

First, create an rt memory space. Currently this space is statically bound
to the value programmer gives. Programmer must know/quess a value high
enough for all stuff that rt must remember: This is done the following way:

	struct RT * rt;

	unless (rt = rt_Create(100)) /* #define unless(x) if (!(x)) */
	   return 20;

This allocates memory for 100 items that rt can remember.

...Now you can for example do the following thing (and then forget the
thing alltogether):

	void closeLib(struct Library * base) { CloseLibrary(base); }
...

	unless (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37))
	   return 20;

	rt_Add(rt, closeLib, DOSBase);

but all this can be done easier by using the provided rt_CloseLib -function:

	unless (rt_CloseLib(rt, &DOSBase, "dos.library", 37))
	   return 20;


As you see, the rt -system takes a pointer to deallocation function and a
data pointer to be given as an argument to that function. At the end of
program execution, the following call will do all these deallocation
function calls in reverse order they were installed.

rt_Delete(rt);


The library in current state provides the following functions:

/* rt.c */
struct RT * rt_Create(int size); /* creates an rt instance */
struct RTNode * rt_Add(struct RT * rt, void * func, void * data);
struct RTNode * rt_Delete(struct RT * rt);

/* rt_remnode.c -- the function below deletes one node */
void rt_RemNode(struct RT * rt, struct RTNode * node);

/* rt_remdata.c -- the function below deletes one node searched by data ptr */
void rt_Remdata(struct RT * rt, void * data);

/* rt_remsome.c -- function deletes multiple entries ... */
void rt_Remdata(struct RT * rt, void * ptr, ULONG flags);

/* rt_exec/rt_openlib.c -- void * as libptr reduces compiler warnings */
struct RTNode * rt_OpenLib(struct RT * rt, void * libptr, 
				char * name, int version); */

/* rt_exec/rt_allocmem.c -- void * as memptr reduces compiler warnings */
struct RTNode * rt_AllocMem(struct RT * rt, void * memptr,
				ULONG size, ULONG flags);

/* rt_dos/rt_open.c */
struct RTNode * rt_Open(struct RT * rt, BPTR * file, char * name, int mode);


See the test program in test directory of this archive. It demonstrates
the way those rt_Rem* -functions work (1384 bytes long and it uses almost
all the functions provided in the library). 

If you want to add your own rt functions to this library, please follow the
convention I've been using in rt_exec/ and rt_dos/ directories. I will gladly
add all your "wrappers" you want to be included in this public distribution
of this library.

All sources and this library is compiled w/ gcc only, since it was so easy
to use gcc cross compiler at sun sparcstation while developing this library
(21" monitor, X and Emacs19 rules).

Well, This documentation should give you a start of trying and using this
library. Please send me comments about the usability and everything you
could think about this piece of work to the address too@cs.hut.fi.

Tomi


Contents of dev/c/rtlibrary.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/include/
-rw-r--r--  1096/10        484     927  52.2% -lh5- bc41 Jan 31  1995 rtlibrary/include/rt.h
-rw-r--r--  1096/10        276     429  64.3% -lh5- a848 Feb  1  1995 rtlibrary/include/rt_dos.h
-rw-r--r--  1096/10        327     539  60.7% -lh5- a951 Feb  1  1995 rtlibrary/include/rt_exec.h
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Jan 31  1995 rtlibrary/lib/
-rw-r--r--  1096/10        810    2204  36.8% -lh5- 92b3 Feb  1  1995 rtlibrary/lib/librt.a
-rw-r--r--  1096/10       1577    3541  44.5% -lh5- 813c Feb  1  1995 rtlibrary/rtlibrary.readme
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/src/
-rw-r--r--  1096/10        672    1227  54.8% -lh5- 2a96 Jan 31  1995 rtlibrary/src/Makefile
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/src/rt/
-rw-r--r--  1096/10        449     900  49.9% -lh5- bc06 Jan 30  1995 rtlibrary/src/rt/rt.c
-rw-r--r--  1096/10        235     324  72.5% -lh5- e785 Jan 30  1995 rtlibrary/src/rt/rt.o
-rw-r--r--  1096/10        386     647  59.7% -lh5- c73f Jan 30  1995 rtlibrary/src/rt/rt_priv.h
-rw-r--r--  1096/10        390     696  56.0% -lh5- 4ea6 Jan  6  1995 rtlibrary/src/rt/rt_remdata.c
-rw-r--r--  1096/10        151     189  79.9% -lh5- dc73 Jan 31  1995 rtlibrary/src/rt/rt_remdata.o
-rw-r--r--  1096/10        325     533  61.0% -lh5- 7f43 Jan  6  1995 rtlibrary/src/rt/rt_remnode.c
-rw-r--r--  1096/10        130     165  78.8% -lh5- 244c Jan 30  1995 rtlibrary/src/rt/rt_remnode.o
-rw-r--r--  1096/10        401     707  56.7% -lh5- b68f Feb  1  1995 rtlibrary/src/rt/rt_remsome.c
-rw-r--r--  1096/10        169     213  79.3% -lh5- 3f67 Feb  1  1995 rtlibrary/src/rt/rt_remsome.o
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/src/rt_dos/
-rw-r--r--  1096/10        333     574  58.0% -lh5- 73ab Jan 30  1995 rtlibrary/src/rt_dos/rt_open.c
-rw-r--r--  1096/10        187     289  64.7% -lh5- 087f Jan 31  1995 rtlibrary/src/rt_dos/rt_open.o
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/src/rt_exec/
-rw-r--r--  1096/10        348     572  60.8% -lh5- c1f9 Feb  1  1995 rtlibrary/src/rt_exec/rt_allocmem.c
-rw-r--r--  1096/10        191     295  64.7% -lh5- 5abb Feb  1  1995 rtlibrary/src/rt_exec/rt_allocmem.o
-rw-r--r--  1096/10        359     603  59.5% -lh5- f34a Feb  1  1995 rtlibrary/src/rt_exec/rt_openlib.c
-rw-r--r--  1096/10        194     295  65.8% -lh5- 4163 Feb  1  1995 rtlibrary/src/rt_exec/rt_openlib.o
drwxr-xr-x  1096/10          0       0 ****** -lhd- 0000 Feb  1  1995 rtlibrary/test/
-rw-r--r--  1096/10        888    1384  64.2% -lh5- ce70 Feb  1  1995 rtlibrary/test/test1
-rw-r--r--  1096/10        692    1884  36.7% -lh5- 2fd8 Feb  1  1995 rtlibrary/test/test1.c
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total        31 files    9974   19137  52.1%            Feb  1  1995
Page generated in 0.02 seconds
Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>