summaryrefslogtreecommitdiff
path: root/src/regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/src/regex.c b/src/regex.c
index f3f70060b2e..751006d57ba 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -212,8 +212,7 @@
static void *
xmalloc (size_t size)
{
- register void *val;
- val = (void *) malloc (size);
+ void *val = malloc (size);
if (!val && size)
{
write (2, "virtual memory exhausted\n", 25);
@@ -225,13 +224,13 @@ xmalloc (size_t size)
static void *
xrealloc (void *block, size_t size)
{
- register void *val;
+ void *val;
/* We must call malloc explicitly when BLOCK is 0, since some
reallocs don't do this. */
if (! block)
- val = (void *) malloc (size);
+ val = malloc (size);
else
- val = (void *) realloc (block, size);
+ val = realloc (block, size);
if (!val && size)
{
write (2, "virtual memory exhausted\n", 25);
@@ -1386,7 +1385,7 @@ typedef struct
#ifdef MATCH_MAY_ALLOCATE
# define INIT_FAIL_STACK() \
do { \
- fail_stack.stack = (fail_stack_elt_t *) \
+ fail_stack.stack = \
REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * TYPICAL_FAILURE_SIZE \
* sizeof (fail_stack_elt_t)); \
\
@@ -1429,8 +1428,7 @@ typedef struct
>= re_max_failures * TYPICAL_FAILURE_SIZE) \
? 0 \
: ((fail_stack).stack \
- = (fail_stack_elt_t *) \
- REGEX_REALLOCATE_STACK ((fail_stack).stack, \
+ = REGEX_REALLOCATE_STACK ((fail_stack).stack, \
(fail_stack).size * sizeof (fail_stack_elt_t), \
MIN (re_max_failures * TYPICAL_FAILURE_SIZE, \
((fail_stack).size * sizeof (fail_stack_elt_t) \
@@ -2141,12 +2139,7 @@ static void
extend_range_table_work_area (struct range_table_work_area *work_area)
{
work_area->allocated += 16 * sizeof (int);
- if (work_area->table)
- work_area->table
- = (int *) realloc (work_area->table, work_area->allocated);
- else
- work_area->table
- = (int *) malloc (work_area->allocated);
+ work_area->table = realloc (work_area->table, work_area->allocated);
}
#if 0
@@ -3741,16 +3734,8 @@ regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct
if (fail_stack.size < re_max_failures * TYPICAL_FAILURE_SIZE)
{
fail_stack.size = re_max_failures * TYPICAL_FAILURE_SIZE;
-
- if (! fail_stack.stack)
- fail_stack.stack
- = (fail_stack_elt_t *) malloc (fail_stack.size
- * sizeof (fail_stack_elt_t));
- else
- fail_stack.stack
- = (fail_stack_elt_t *) realloc (fail_stack.stack,
- (fail_stack.size
- * sizeof (fail_stack_elt_t)));
+ falk_stack.stack = realloc (fail_stack.stack,
+ fail_stack.size * sizeof *falk_stack.stack);
}
regex_grow_registers (num_regs);
@@ -6408,13 +6393,13 @@ re_comp (const char *s)
if (!re_comp_buf.buffer)
{
- re_comp_buf.buffer = (unsigned char *) malloc (200);
+ re_comp_buf.buffer = malloc (200);
if (re_comp_buf.buffer == NULL)
/* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
re_comp_buf.allocated = 200;
- re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
+ re_comp_buf.fastmap = malloc (1 << BYTEWIDTH);
if (re_comp_buf.fastmap == NULL)
/* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
@@ -6498,15 +6483,13 @@ regcomp (regex_t *__restrict preg, const char *__restrict pattern,
preg->used = 0;
/* Try to allocate space for the fastmap. */
- preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
+ preg->fastmap = malloc (1 << BYTEWIDTH);
if (cflags & REG_ICASE)
{
unsigned i;
- preg->translate
- = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
- * sizeof (*(RE_TRANSLATE_TYPE)0));
+ preg->translate = malloc (CHAR_SET_SIZE * sizeof *preg->translate);
if (preg->translate == NULL)
return (int) REG_ESPACE;