]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/comp_hash.c
ncurses 5.0
[ncurses.git] / ncurses / tinfo / comp_hash.c
similarity index 96%
rename from ncurses/comp_hash.c
rename to ncurses/tinfo/comp_hash.c
index bd9d52d7690c5806a4e1dd9841a7f2007e89cbfb..7e0bdd0524fe796cdaa00738d135fb31980fe661 100644 (file)
@@ -49,7 +49,7 @@
 #define DEBUG(level, params) /*nothing*/
 #endif
 
-MODULE_ID("$Id: comp_hash.c,v 1.16 1998/02/11 12:13:53 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.21 1999/06/26 21:25:11 tom Exp $")
 
 static  int hash_function(const char *);
 
@@ -63,6 +63,11 @@ static  int hash_function(const char *);
  */
 
 #ifdef MAIN_PROGRAM
+
+#undef MODULE_ID
+#define MODULE_ID(id) /*nothing*/
+#include <tinfo/doalloc.c>
+
 static void _nc_make_hash_table(struct name_table_entry *table,
                     struct name_table_entry **hash_table)
 {
@@ -180,18 +185,6 @@ struct name_table_entry    const *ptr;
  * performance enhancement).
  */
 
-#if !HAVE_STRDUP
-static char *strdup (char *s)
-{
-  char *p;
-
-  p = malloc(strlen(s)+1);
-  if (p)
-    strcpy(p,s);
-  return(p);
-}
-#endif /* not HAVE_STRDUP */
-
 #define MAX_COLUMNS BUFSIZ     /* this _has_ to be worst-case */
 
 static char **parse_columns(char *buffer)
@@ -200,8 +193,8 @@ static char **parse_columns(char *buffer)
 
        int col = 0;
 
-       if (list == 0)
-               list = typeCalloc(char *, MAX_COLUMNS);
+       if (list == 0 && (list = typeCalloc(char *, MAX_COLUMNS)) == 0)
+               return(0);
 
        if (*buffer != '#') {
                while (*buffer != '\0') {
@@ -310,9 +303,9 @@ int main(int argc, char **argv)
        printf("{\n");
        for (n = 0; n < HASHTABSIZE; n++) {
                if (hash_table[n] != 0) {
-                       sprintf(buffer, "_nc_%s_table + %3d",
+                       sprintf(buffer, "_nc_%s_table + %3ld",
                                root_name,
-                               hash_table[n] - name_table);
+                               (long) (hash_table[n] - name_table));
                } else {
                        strcpy(buffer, "0");
                }