summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorvern <vern>1993-12-15 10:23:16 +0000
committervern <vern>1993-12-15 10:23:16 +0000
commit29a67631e745c5cb20a59eac15c5b6ab6af4cafd (patch)
treee05618a05bbb77f78dd5ae935f9e036c3f7c87c7 /misc.c
parenteb24047c4cb6ae5f0b2229ac4c05203429b434d9 (diff)
downloadflex-29a67631e745c5cb20a59eac15c5b6ab6af4cafd.tar.gz
alloc routines take unsigned
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/misc.c b/misc.c
index b94e02e..de37976 100644
--- a/misc.c
+++ b/misc.c
@@ -26,7 +26,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-/* $Header: /cvsroot/flex/flex/misc.c,v 2.32 1993/12/15 10:08:38 vern Exp $ */
+/* $Header: /cvsroot/flex/flex/misc.c,v 2.33 1993/12/15 10:23:20 vern Exp $ */
#include "flexdef.h"
@@ -62,14 +62,7 @@ void *allocate_array( size, element_size )
int size, element_size;
{
register void *mem;
- int num_bytes = element_size * size;
-
- /* On 16-bit int machines (e.g., 80286) we might be trying to
- * allocate more than a signed int can hold, and that won't
- * work. Cheap test:
- */
- if ( num_bytes <= 0 )
- flexfatal( "request for < 1 byte in allocate_array()" );
+ unsigned int num_bytes = element_size * size;
mem = yy_flex_alloc( num_bytes );
@@ -178,12 +171,14 @@ register char *str;
{
register char *c;
char *copy;
+ unsigned int size;
/* find length */
for ( c = str; *c; ++c )
;
- copy = (char *) yy_flex_alloc( (c - str + 1) * sizeof( char ) );
+ size = (c - str + 1) * sizeof( char );
+ copy = (char *) yy_flex_alloc( size );
if ( copy == NULL )
flexfatal( "dynamic memory failure in copy_string()" );
@@ -750,12 +745,7 @@ void *array;
int size, element_size;
{
register void *new_array;
- int num_bytes = element_size * size;
-
- /* Same worry as in allocate_array(): */
- if ( num_bytes <= 0 )
- flexfatal(
- "attempt to increase array size by less than 1 byte" );
+ unsigned int num_bytes = element_size * size;
new_array = yy_flex_realloc( array, num_bytes );
@@ -855,7 +845,7 @@ int element_v, element_n;
void *yy_flex_xmalloc( size )
int size;
{
- void *result = yy_flex_alloc( size );
+ void *result = yy_flex_alloc( (unsigned) size );
if ( ! result )
flexfatal( "memory allocation failed in yy_flex_xmalloc()" );