diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-03-21 11:03:15 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-03-21 11:03:15 -0700 |
commit | b1f961e1fa871419e3e75759ad2fefee032ebff5 (patch) | |
tree | 4c399696c8e55f7cc661dcd04ab9654fdf6a89be /lib-src/ebrowse.c | |
parent | 58cb46fbf4a0d3b37cb9cf2b07446eaa48663693 (diff) | |
download | emacs-b1f961e1fa871419e3e75759ad2fefee032ebff5.tar.gz |
* ebrowse.c: Use size_t, not int, for sizes.
This avoids a warning with gcc -Wstrict-overflow, and works
better for very large objects.
(inbuffer_size): Now size_t. All uses changed.
(xmalloc, xrealloc, operator_name, process_file): Use size_t for
sizes. Don't bother testing whether a size_t value can be negative.
Diffstat (limited to 'lib-src/ebrowse.c')
-rw-r--r-- | lib-src/ebrowse.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 113b6fdfe40..7871a804997 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -378,7 +378,7 @@ int max_regexp = 50; char *inbuffer; char *in; -int inbuffer_size; +size_t inbuffer_size; /* Return the current buffer position in the input file. */ @@ -492,7 +492,7 @@ yyerror (const char *format, const char *s) available. */ static void * -xmalloc (int nbytes) +xmalloc (size_t nbytes) { void *p = malloc (nbytes); if (p == NULL) @@ -507,7 +507,7 @@ xmalloc (int nbytes) /* Like realloc but print an error and exit if out of memory. */ static void * -xrealloc (void *p, int sz) +xrealloc (void *p, size_t sz) { p = realloc (p, sz); if (p == NULL) @@ -2792,10 +2792,10 @@ parse_classname (void) static char * operator_name (int *sc) { - static int id_size = 0; + static size_t id_size = 0; static char *id = NULL; const char *s; - int len; + size_t len; MATCH (); @@ -2811,7 +2811,7 @@ operator_name (int *sc) len = strlen (s) + 10; if (len > id_size) { - int new_size = max (len, 2 * id_size); + size_t new_size = max (len, 2 * id_size); id = (char *) xrealloc (id, new_size); id_size = new_size; } @@ -2832,7 +2832,7 @@ operator_name (int *sc) } else { - int tokens_matched = 0; + size_t tokens_matched = 0; len = 20; if (len > id_size) @@ -2853,7 +2853,7 @@ operator_name (int *sc) len += strlen (s) + 2; if (len > id_size) { - int new_size = max (len, 2 * id_size); + size_t new_size = max (len, 2 * id_size); id = (char *) xrealloc (id, new_size); id_size = new_size; } @@ -3550,7 +3550,7 @@ process_file (char *file) fp = open_file (file); if (fp) { - int nread, nbytes; + size_t nread, nbytes; /* Give a progress indication if needed. */ if (f_very_verbose) @@ -3574,12 +3574,10 @@ process_file (char *file) } nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp); - if (nbytes <= 0) + if (nbytes == 0) break; nread += nbytes; } - if (nread < 0) - nread = 0; inbuffer[nread] = '\0'; /* Reinitialize scanner and parser for the new input file. */ |