BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
maxlenlib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"

Functions

void domaxlen (void)
void domaxlenl (void)
void echk1 (void)
static ULONG maxlen (UBYTE **var, ULONG n, const UBYTE *mem)
static ULONG domaxlenl_c (UBYTE **var, ULONG n, const UBYTE *mem)
 MaxLen a$=n (tokens maxlen $D000 for a global, lmaxlen $D001 for a local string) - give a string variable a buffer of n characters.
 BLITZ_ALIAS (domaxlenl, domaxlenl_c)
static void echk1_c (LONG n)
 The error check of MaxLen (debugger only): the length must not be negative.

Function Documentation

◆ BLITZ_ALIAS()

BLITZ_ALIAS ( domaxlenl ,
domaxlenl_c  )

◆ domaxlen()

void domaxlen ( void )

◆ domaxlenl()

void domaxlenl ( void )

◆ domaxlenl_c()

ULONG domaxlenl_c ( UBYTE ** var,
ULONG n,
const UBYTE * mem )
static

MaxLen a$=n (tokens maxlen $D000 for a global, lmaxlen $D001 for a local string) - give a string variable a buffer of n characters.

domaxlenl - local string; domaxlen: global string, ADDQ #8,a6 first (an assembler entry in front of the C function, as in the original: a6 stays +8). The old memory is freed (len = alloc'd+9) and the variable cleared; for n <> 0, n+9 bytes are allocated: alloc'd len = n, string len 0, empty string. A statement of the compiler (perf-analysis thunks.md 1.4): nothing is live across it, no third-party library calls it; the C function keeps d2-d7/a2-a5 (and a6 for domaxlenl), a0 and a1 are free (the original leaves them unchanged on some paths only: no old memory / n = 0). DIFF: d2/a2 are kept (the original leaves n and the variable address there).

Errors: n < 0 is runtime error 1, but only with the debugger (echk1).

Parameters
vard0: the address of the string variable.
nd1: the maximum length.
mema6: memlib's membase table (!libs 65530,la6); +8 for the global versions.
Returns
d0: the new variable contents (0 for n = 0).

◆ echk1()

void echk1 ( void )

◆ echk1_c()

void echk1_c ( LONG n)
static

The error check of MaxLen (debugger only): the length must not be negative.

echk1 - TST.l d1:BMI err1:RTS; err1: MOVEQ #1,d0:TRAP #0 (an error number instead of a message pointer). Keeps all registers (d0 only changed on the error).

Parameters
nd1: the maximum length.

◆ maxlen()

ULONG maxlen ( UBYTE ** var,
ULONG n,
const UBYTE * mem )
static