debuggers.hg
changeset 4946:03d2d6123dd2
bitkeeper revision 1.1389.1.61 (4284f1ddAO6PwLXgaP83tPIB0NH4cw)
Cset exclude: cl349@firebug.cl.cam.ac.uk|ChangeSet|20050513143651|29037
Cset exclude: cl349@firebug.cl.cam.ac.uk|ChangeSet|20050513143651|29037
author | smh22@firebug.cl.cam.ac.uk |
---|---|
date | Fri May 13 18:28:45 2005 +0000 (2005-05-13) |
parents | 8b3e823884db |
children | 650b80c41719 |
files | tools/libxutil/sxpr_parser.c tools/libxutil/sxpr_parser.h |
line diff
1.1 --- a/tools/libxutil/sxpr_parser.c Fri May 13 18:20:40 2005 +0000 1.2 +++ b/tools/libxutil/sxpr_parser.c Fri May 13 18:28:45 2005 +0000 1.3 @@ -160,8 +160,6 @@ void Parser_free(Parser *z){ 1.4 if(!z) return; 1.5 objfree(z->val); 1.6 z->val = ONONE; 1.7 - if (z->buf) 1.8 - deallocate(z->buf); 1.9 deallocate(z); 1.10 } 1.11 1.12 @@ -173,7 +171,6 @@ Parser * Parser_new(void){ 1.13 1.14 if(!z) goto exit; 1.15 err = 0; 1.16 - z->buf = NULL; 1.17 reset(z); 1.18 exit: 1.19 if(err){ 1.20 @@ -204,16 +201,8 @@ static int inputchar(Parser *p, char c){ 1.21 static int savechar(Parser *p, char c){ 1.22 int err = 0; 1.23 if(p->buf_i >= p->buf_n){ 1.24 - char *nbuf; 1.25 - nbuf = allocate(2 * (p->buf_n + 1)); 1.26 - if (nbuf == NULL) { 1.27 - err = -ENOMEM; 1.28 - goto exit; 1.29 - } 1.30 - memcpy(nbuf, p->buf, p->buf_i); 1.31 - deallocate(p->buf); 1.32 - p->buf = nbuf; 1.33 - p->buf_n = 2 * (p->buf_n + 1) - 1; 1.34 + err = -ENOMEM; 1.35 + goto exit; 1.36 } 1.37 p->buf[p->buf_i] = c; 1.38 p->buf_i++; 1.39 @@ -698,16 +687,8 @@ int end_list(Parser *p){ 1.40 static void reset(Parser *z){ 1.41 IOStream *error_out = z->error_out; 1.42 int flags = z->flags; 1.43 - int buf_n = z->buf_n; 1.44 - char *buf = z->buf; 1.45 memzero(z, sizeof(Parser)); 1.46 - if (buf) { 1.47 - z->buf = buf; 1.48 - z->buf_n = buf_n; 1.49 - } else { 1.50 - z->buf = (char *)allocate(PARSER_BUF_SIZE); 1.51 - z->buf_n = PARSER_BUF_SIZE - 1; 1.52 - } 1.53 + z->buf_n = sizeof(z->buf) - 1; 1.54 z->buf_i = 0; 1.55 z->line_no = 1; 1.56 z->char_no = 0;
2.1 --- a/tools/libxutil/sxpr_parser.h Fri May 13 18:20:40 2005 +0000 2.2 +++ b/tools/libxutil/sxpr_parser.h Fri May 13 18:28:45 2005 +0000 2.3 @@ -28,7 +28,7 @@ 2.4 /** Size of a parser input buffer. 2.5 * Tokens read must fit into this size (including trailing null). 2.6 */ 2.7 -#define PARSER_BUF_SIZE 1024 2.8 +#define PARSER_BUF_SIZE 4096 2.9 2.10 struct Parser; 2.11 typedef int ParserStateFn(struct Parser *, char c); 2.12 @@ -60,7 +60,7 @@ typedef struct Parser { 2.13 /** Lookahead character. */ 2.14 char c; 2.15 /** Buffer for reading tokens. */ 2.16 - char *buf; 2.17 + char buf[PARSER_BUF_SIZE]; 2.18 /** Size of token buffer. */ 2.19 int buf_n; 2.20 int buf_i;