gno/bin/gsh/bufpool.asm
tribby e7f2691599 Changes for gsh version 2.0d7:
Fixed several memory leaks.

Prefix command without any parameter (to list the prefixes) would cause
memory corruption when prefix had been invoked previously with a parameter.

Sourcing a command file from within an exec file could cause gsh to
wait forever, depending upon the commands executed in the sourced file.

All built-in commands return appropriate status: 1 for error, 0 for no error.

Fixed several cases where incorrect value was set in $status.

Added usage strings for tset, hash, commands, and history.

Fixed memory corruption error when edit command had no parameters.

When system() is called with pointer = NULL or with a command string that
causes gsh to detect an error (e.g., incompatibility with | and <), return
status of -1. In other cases, return process's status rather than always 0.

System would crash when output from a non-forked command was piped to
another process; for example   clear | cat > /tmp/list
1998-12-21 23:57:08 +00:00

129 lines
2.6 KiB
NASM

**************************************************************************
*
* The GNO Shell Project
*
* Developed by:
* Jawaid Bazyar
* Tim Meekins
*
* $Id: bufpool.asm,v 1.6 1998/12/21 23:57:04 tribby Exp $
*
**************************************************************************
*
* BUFPOOL
* By Tim Meekins
* Modified by Dave Tribby for GNO 2.0.6 (256-byte buffer code removed)
*
* This is the buffer pool
*
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | |
* ^ ^ ^ ^ ^ ^
**************************************************************************
*
* Interfaces defined in this file:
* The alloc routine is a jsl without any stack params.
* Pointer to requested buffer is returned in X/A registers.
* alloc1024
* The free routine takes the address from the X/A registers
* free1024
*
* bufpool data:
* pool1024 dc i4'0'
* pool1024mutex key
*
**************************************************************************
mcopy /obj/gno/bin/gsh/bufpool.mac
dummybufpool start ; ends up in .root
end
**************************************************************************
*
* Get a buffer of size 1024
*
**************************************************************************
alloc1024 START
using bufpool
lock pool1024mutex
lda pool1024 If pool pointer
ora pool1024+2 isn't NULL,
beq allocbuf
phd
ph4 pool1024 Push pool pointer on stack.
tsc
tcd
lda [1] Replace pool pointer with
sta pool1024 the address it points to.
ldy #2
lda [1],y
sta pool1024+2
unlock pool1024mutex
pla
plx
pld
rtl Return to caller.
;
; No memory in free pool; must allocate a new block.
;
allocbuf unlock pool1024mutex
ph4 #1024
~NEW
rtl
END
**************************************************************************
*
* Free a buffer of size 1024, putting it into the free pool
*
**************************************************************************
free1024 START
using bufpool
phd
phx
pha
tsc
tcd
lock pool1024mutex
lda pool1024 Move current head of pool list
sta [1] into the buffer being freed.
ldy #2
lda pool1024+2
sta [1],y
lda 1 Put address of buffer being freed
sta pool1024 into the pool list head.
lda 3
sta pool1024+2
unlock pool1024mutex
pla
plx
pld
rtl Return to caller.
END
**************************************************************************
*
* Buffer pool data
*
**************************************************************************
bufpool DATA
pool1024 dc i4'0' Head of free pool list.
pool1024mutex key Mutual exclusion when modifying list.
END