summaryrefslogtreecommitdiffstats
path: root/sys/ddb
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1997-11-09 06:30:29 +0000
committermsmith <msmith@FreeBSD.org>1997-11-09 06:30:29 +0000
commit67ba7220fd45bbe2b4448467dfc3e852b313ec21 (patch)
tree189cd1ba9fa3cf5db5397f3f00fd52b2e0c1a20e /sys/ddb
parenteae0088b91cbc4408b450aa68745064732b86734 (diff)
downloadFreeBSD-src-67ba7220fd45bbe2b4448467dfc3e852b313ec21.zip
FreeBSD-src-67ba7220fd45bbe2b4448467dfc3e852b313ec21.tar.gz
A better fix for the ddb command history buffer problem; use a static
buffer instead of trying to use malloc() in the input routine. Submitted by: john hood <cgull@smoke.marlboro.vt.us>
Diffstat (limited to 'sys/ddb')
-rw-r--r--sys/ddb/db_input.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c
index 888aa83..d055263 100644
--- a/sys/ddb/db_input.c
+++ b/sys/ddb/db_input.c
@@ -23,7 +23,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $Id: db_input.c,v 1.19 1997/08/17 21:21:50 joerg Exp $
+ * $Id: db_input.c,v 1.20 1997/11/07 02:34:50 msmith Exp $
*/
/*
@@ -58,8 +58,9 @@ static char * db_le; /* one past last character */
* Simple input line history support.
*/
static char * db_lhistory;
+static char db_lhistory_buffer[2048];
static int db_lhistlsize, db_lhistidx, db_lhistcur;
-#define DB_LHIST_NLINES 10
+static int db_lhist_nlines;
#define CTRL(c) ((c) & 0x1f)
#define isspace(c) ((c) == ' ' || (c) == '\t')
@@ -312,15 +313,14 @@ db_readline(lstart, lsize)
{
if (db_lhistory && lsize != db_lhistlsize) {
/* Should not happen, but to be sane, throw history away. */
- FREE(db_lhistory, M_TEMP);
- db_lhistory = 0;
+ db_lhistory = NULL;
}
- if (db_lhistory == 0) {
+ if (db_lhistory == NULL) {
/* Initialize input line history. */
+ db_lhistory = db_lhistory_buffer;
+ db_lhist_nlines = (sizeof db_lhistory_buffer) / lsize;
db_lhistlsize = lsize;
db_lhistidx = -1;
- MALLOC(db_lhistory, char *, lsize * DB_LHIST_NLINES,
- M_TEMP, M_NOWAIT);
}
db_lhistcur = db_lhistidx;
@@ -339,10 +339,10 @@ db_readline(lstart, lsize)
if (db_lhistory && (db_le - db_lbuf_start > 1)) {
/* Maintain input line history for non-empty lines. */
- if (++db_lhistidx == DB_LHIST_NLINES) {
+ if (++db_lhistidx == db_lhist_nlines) {
/* Rotate history. */
ovbcopy(db_lhistory + db_lhistlsize, db_lhistory,
- db_lhistlsize * (DB_LHIST_NLINES - 1));
+ db_lhistlsize * (db_lhist_nlines - 1));
db_lhistidx--;
}
bcopy(lstart, db_lhistory + (db_lhistidx * db_lhistlsize),
OpenPOWER on IntegriCloud