Lugaru's Epsilon
Editor 14.04

Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      . . .
      Operating System Primitives
         System Primitives
         Window System Primitives
         Calling Windows DLLs
         Running a Process
      Control Primitives
         . . .
         Modifying Strings
         Byte Arrays
         Memory Allocation
         The Name Table
         Built-in and User Variables
         . . .
      Input Primitives
         The Mouse
         Window Events
         . . .
         Binding Primitives
      . . .

Previous   Up    Next
Byte Arrays  Primitives and EEL Subroutines   The Name Table

Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Control Primitives >

Memory Allocation

char *malloc(int size)
char *realloc(char *ptr, int size)
free(char *ptr)

Epsilon maintains a pool of memory and provides primitives for allocating and deallocating blocks of any size. The malloc( ) primitive takes an int giving the number of characters of space required, and returns a pointer to a block of that size.

The realloc( ) primitive takes a pointer previously allocated with malloc( ). First, it tries to expand the block to the requested size. If it cannot do that, it allocates another block of the requested size, then copies the old characters to the new block. In either case, it returns a pointer to a block of the requested size.

The free( ) primitive takes a pointer that malloc( ) previously returned and puts it back into the storage pool. Never use a block after you free it.

char *strsave(char *s)
char *strkeep(char *s)

For convenience, Epsilon provides a primitive to copy a string to an allocated block of the proper size. The strsave( ) primitive is used when a string needed later is stored in an array that must be reused. The primitive returns a pointer to the copy of the string it makes. The free( ) primitive may be given this pointer when the string is no longer needed.

The strkeep( ) subroutine also saves a string so it may be used later, returning a pointer to the copy. It's often used to store a mode name for use with the major_mode variable. Unlike strsave( ), calling strkeep( ) on the same text multiple times always reuses the same saved block. Strings allocated by strkeep( ) may not be freed; they remain until Epsilon exits.

user int mem_in_use;

The mem_in_use variable gives the space in bytes Epsilon is now using for miscellaneous storage (not including buffer text).

set_swapname(char *path)

If Epsilon can't fit all your files in available memory, it will swap parts to disk. The parts are contained in one or more swap files. The set_swapname( ) primitive tells Epsilon what directories to use for swap files, if it needs them. The argument is a string containing a list of directories in which to place swap files, as described under the -fs command line flag. After swapping has begun, this primitive has no effect. Supplying an empty argument "" makes Epsilon use the standard place for swapping, as described under the -fs command line switch in Epsilon Command Line Flags.

Previous   Up    Next
Byte Arrays  Primitives and EEL Subroutines   The Name Table

Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.