BALLOC(3R)

NAME
balloc, bfree - bitmap allocation

SYNOPSIS
#include <dmd.h>

Bitmap *balloc (r)
Rectangle r;

void bfree (b)
Bitmap *b;

DESCRIPTION
The balloc function either returns a pointer to a Bitmap large enough to contain the Rectangle r, or a 0 (NULL) for failure. The bitmap is allocated first by a call to alloc(3R) for the Bitmap data structure and then to gcalloc(3R) for the actual Bitmap storage. The coordinate system inside the Bitmap is set by r. The origin and corner of the Bitmap are those of r which must itself be in screen coordinates.

The bfree frees the storage associated with a Bitmap allocated by balloc.

The terminal automatically frees all memory balloc'ed by a process when the process terminates or when the window it is running in is deleted. However, it is recommended that a process free its balloc'ed memory when the storage is no longer needed so that other processes will be able to use it.

EXAMPLE
The following example shows the use of balloc and bfree in dynamically allocating memory for a Bitmap.

    #include <dmd.h>
    main()
    {
        Bitmap *b;
        Bitmap *balloc();
        void bfree();
        b = balloc (Rect (0, 0, 48, 48));
        .
        .
        .
        bfree (b);
    }

SEE ALSO
alloc(3R), gcalloc(3R), structures(3R).

BUGS

If the bitmap image requested needs over 7000000 bytes, balloc may produce a process exception. If this happens, gcalloc memory will be corrupted, and other programs running in the terminal may be damaged.