- Rename strieq() to patheq() for clarity.
authorPaul Smith <psmith@gnu.org>
Thu, 1 Jul 2010 05:59:08 +0000 (05:59 +0000)
committerPaul Smith <psmith@gnu.org>
Thu, 1 Jul 2010 05:59:08 +0000 (05:59 +0000)
- Convert xmalloc/memset pairs to xcalloc.

ChangeLog
dir.c
file.c
job.c
make.h

index 5391e16145aff9f937e79b047371b6f9eaf37142..58eb673bee28519176cb98664d2fd09b3653010b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-01-10  Paul Smith  <psmith@gnu.org>
+
+       * make.h (patheq): Rename strieq() to patheq() for clarity.
+       * dir.c (dir_contents_file_exists_p): Use it.
+
+       * dir.c (file_impossible): Convert xmalloc/memset to xcalloc.
+       * file.c (enter_file): Ditto.
+       * job.c (new_job): Ditto.
+
 2009-12-11  Eli Zaretskii  <eliz@gnu.org>
 
        * job.c (construct_command_argv_internal) <sh_cmds_dos>
diff --git a/dir.c b/dir.c
index e127fc12a45fcd3280a2d36cb033da0a44acee8e..4224abbed45505240db6939144c5f888369d28ee 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -721,7 +721,7 @@ dir_contents_file_exists_p (struct directory_contents *dir,
          hash_insert_at (&dir->dirfiles, df, dirfile_slot);
        }
       /* Check if the name matches the one we're searching for.  */
-      if (filename != 0 && strieq (d->d_name, filename))
+      if (filename != 0 && patheq (d->d_name, filename))
         return 1;
     }
 
@@ -872,12 +872,9 @@ file_impossible (const char *filename)
     }
 
   if (dir->contents == 0)
-    {
-      /* The directory could not be stat'd.  We allocate a contents
-        structure for it, but leave it out of the contents hash table.  */
-      dir->contents = xmalloc (sizeof (struct directory_contents));
-      memset (dir->contents, '\0', sizeof (struct directory_contents));
-    }
+    /* The directory could not be stat'd.  We allocate a contents
+       structure for it, but leave it out of the contents hash table.  */
+    dir->contents = xcalloc (sizeof (struct directory_contents));
 
   if (dir->contents->dirfiles.ht_vec == 0)
     {
diff --git a/file.c b/file.c
index d068b34f52b00415a38f13baba8ccd5ebf0f7f9d..c3f767893d47eded1e7e5a3f9167f999062c6600 100644 (file)
--- a/file.c
+++ b/file.c
@@ -181,8 +181,7 @@ enter_file (const char *name)
   if (! HASH_VACANT (f) && !f->double_colon)
     return f;
 
-  new = xmalloc (sizeof (struct file));
-  memset (new, '\0', sizeof (struct file));
+  new = xcalloc (sizeof (struct file));
   new->name = new->hname = name;
   new->update_status = -1;
 
diff --git a/job.c b/job.c
index 1db72174efe7db04d3ea712ca1a4de7e3b171a33..edbf569c54d3c2330fd4cd2ca1a354aab83a9a66 100644 (file)
--- a/job.c
+++ b/job.c
@@ -1611,8 +1611,7 @@ new_job (struct file *file)
   /* Start the command sequence, record it in a new
      `struct child', and add that to the chain.  */
 
-  c = xmalloc (sizeof (struct child));
-  memset (c, '\0', sizeof (struct child));
+  c = xcalloc (sizeof (struct child));
   c->file = file;
   c->command_lines = lines;
   c->sh_batch_file = NULL;
diff --git a/make.h b/make.h
index 2841c7fe6c5dc7a4b9403ac677a85a1195508230..65faadcfb99e94f3d1b14a69b4202c3a07b7d0dc 100644 (file)
--- a/make.h
+++ b/make.h
@@ -264,23 +264,23 @@ char *strsignal (int signum);
    host does not conform to POSIX.  */
 #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
 
-#ifndef iAPX286
-# define streq(a, b) \
+/* Test if two strings are equal. Is this worthwhile?  Should be profiled.  */
+#define streq(a, b) \
    ((a) == (b) || \
     (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
-# ifdef HAVE_CASE_INSENSITIVE_FS
-#  define strieq(a, b) \
+
+/* Test if two strings are equal, but match case-insensitively on systems
+   which have case-insensitive filesystems.  Should only be used for
+   filenames!  */
+#ifdef HAVE_CASE_INSENSITIVE_FS
+# define patheq(a, b) \
     ((a) == (b) \
      || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
          && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
-# else
-#  define strieq(a, b) streq(a, b)
-# endif
 #else
-/* Buggy compiler can't handle this.  */
-# define streq(a, b) (strcmp ((a), (b)) == 0)
-# define strieq(a, b) (strcmp ((a), (b)) == 0)
+# define patheq(a, b) streq(a, b)
 #endif
+
 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
 
 #if defined(__GNUC__) || defined(ENUM_BITFIELDS)