summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2002-10-31 12:30:27 +0000
committerBruno Haible <bruno@clisp.org>2002-10-31 12:30:27 +0000
commit00c5953c20988612625afb377ca88e61c390aff8 (patch)
tree9f3cccfb41d86e2fc8232b1b75f3eea27cd7a573 /src
parenta07f46bd1d8e30fd1969da7119c95d88ed2054ce (diff)
downloadgperf-00c5953c20988612625afb377ca88e61c390aff8.tar.gz
Use the standard 'new' operator.
Diffstat (limited to 'src')
-rw-r--r--src/configure.in12
-rw-r--r--src/key-list.cc39
-rw-r--r--src/main.cc27
-rw-r--r--src/options.h11
4 files changed, 8 insertions, 81 deletions
diff --git a/src/configure.in b/src/configure.in
index 7691e0d..27a68e1 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,6 +1,6 @@
dnl autoconf configuration for gperf/src
-dnl Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+dnl Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc.
dnl written by Douglas C. Schmidt (schmidt@ics.uci.edu)
dnl
dnl This file is part of GNU GPERF.
@@ -42,16 +42,6 @@ dnl
dnl
dnl checks for functions and declarations
dnl
-AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h)
- dnl DEFs HAVE_UNISTD_H, HAVE_SYS_TIME_H, HAVE_SYS_RESOURCE_H
-if test $ac_cv_header_sys_resource_h = yes; then
-AC_CHECK_FUNCS(getrlimit)
- dnl DEFS HAVE_GETRLIMIT
-if test $ac_cv_func_getrlimit = yes; then
-AC_CHECK_FUNCS(setrlimit)
- dnl DEFS HAVE_SETRLIMIT
-fi
-fi
dnl
dnl checks for libraries
dnl
diff --git a/src/key-list.cc b/src/key-list.cc
index ee9b115..f2fb7a2 100644
--- a/src/key-list.cc
+++ b/src/key-list.cc
@@ -382,19 +382,8 @@ Key_List::read_keys (void)
/* Hash table this number of times larger than keyword number. */
int table_size = (list_len = total_keys) * TABLE_MULTIPLE;
-
-#if LARGE_STACK_ARRAYS
- /* By allocating the memory here we save on dynamic allocation overhead.
- Table must be a power of 2 for the hash function scheme to work. */
- List_Node *table[POW (table_size)];
-#else
- // Note: we don't use new, because that invokes a custom operator new.
- int malloc_size = POW (table_size) * sizeof(List_Node*);
- if (malloc_size == 0) malloc_size = 1;
- List_Node **table = (List_Node**)malloc(malloc_size);
- if (table == NULL)
- abort ();
-#endif
+ /* Table must be a power of 2 for the hash function scheme to work. */
+ List_Node **table = new List_Node*[POW (table_size)];
/* Make large hash table for efficiency. */
Hash_Table found_link (table, table_size, option[NOLENGTH]);
@@ -436,9 +425,7 @@ Key_List::read_keys (void)
min_key_len = temp->key_length;
}
-#if !LARGE_STACK_ARRAYS
- free ((char *) table);
-#endif
+ delete[] table;
/* Exit program if links exists and option[DUP] not set, since we can't continue */
if (total_duplicates)
@@ -1338,18 +1325,8 @@ Key_List::output_lookup_array (void)
int count; /* Number of consecutive duplicates at this index. */
};
-#if LARGE_STACK_ARRAYS
- duplicate_entry duplicates[total_duplicates];
- int lookup_array[max_hash_value + 1 + 2*total_duplicates];
-#else
- // Note: we don't use new, because that invokes a custom operator new.
- duplicate_entry *duplicates = (duplicate_entry *)
- malloc (total_duplicates * sizeof(duplicate_entry) + 1);
- int *lookup_array = (int *)
- malloc ((max_hash_value + 1 + 2*total_duplicates) * sizeof(int));
- if (duplicates == NULL || lookup_array == NULL)
- abort();
-#endif
+ duplicate_entry *duplicates = new duplicate_entry[total_duplicates];
+ int *lookup_array = new int[max_hash_value + 1 + 2*total_duplicates];
int lookup_array_size = max_hash_value + 1;
duplicate_entry *dup_ptr = &duplicates[0];
int *lookup_ptr = &lookup_array[max_hash_value + 1 + 2*total_duplicates];
@@ -1486,10 +1463,8 @@ Key_List::output_lookup_array (void)
}
printf ("\n%s };\n\n", indent);
-#if !LARGE_STACK_ARRAYS
- free ((char *) duplicates);
- free ((char *) lookup_array);
-#endif
+ delete[] duplicates;
+ delete[] lookup_array;
}
}
diff --git a/src/main.cc b/src/main.cc
index 723a4e3..63abfd2 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -21,20 +21,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
/* Simple driver program for the Gen_Perf.hash function generator.
Most of the hard work is done in class Gen_Perf and its class methods. */
-#include "config.h"
-#include <sys/types.h>
-#if LARGE_STACK_ARRAYS && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#endif
-
#include <stdio.h>
#include "options.h"
#include "gen-perf.h"
@@ -42,19 +28,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
int
main (int argc, char *argv[])
{
-#if LARGE_STACK_ARRAYS && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK)
- /* Get rid of any avoidable limit on stack size. */
- {
- struct rlimit rlim;
- if (getrlimit (RLIMIT_STACK, &rlim) == 0)
- if (rlim.rlim_cur < rlim.rlim_max)
- {
- rlim.rlim_cur = rlim.rlim_max;
- setrlimit (RLIMIT_STACK, &rlim);
- }
- }
-#endif /* RLIMIT_STACK */
-
/* Sets the Options. */
option (argc, argv);
diff --git a/src/options.h b/src/options.h
index 0b5b88e..d4599dc 100644
--- a/src/options.h
+++ b/src/options.h
@@ -131,17 +131,6 @@ private:
/* Global option coordinator for the entire program. */
extern Options option;
-/* Set to 1 if your want to stack-allocate some large arrays.
- This requires compiler support for variable-size arrays on the stack
- (not ANSI). */
-#ifndef LARGE_STACK_ARRAYS
-#if defined(__GNUG__) && !defined(__STRICT_ANSI__)
-#define LARGE_STACK_ARRAYS 1
-#else
-#define LARGE_STACK_ARRAYS 0
-#endif
-#endif
-
#ifdef __OPTIMIZE__
#define INLINE inline