* amd/sun_map_parse.y: instead of using a custom FOO_alloc()
authorErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2005 02:28:38 +0000 (02:28 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2005 02:28:38 +0000 (02:28 +0000)
function, use Amd's CALLOC(struct FOO) macro.

* amd/sun_map.h: remove extern definitions to functions no longer
needed.

* amd/sun_map.c: removed superfluous *_alloc() functions, some of
which caused conflicts with same-named symbols in the parser
(since we rename 'yyalloc' to 'sun_map_alloc').

ChangeLog
amd/sun_map.c
amd/sun_map.h
amd/sun_map_parse.y

index a091e45090dc8a986a203d75b108e5eebd23bc51..9cd1e96cdc92c5edcfefe16546af09b10a4ab03d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2005-08-11  Erez Zadok  <ezk@cs.sunysb.edu>
 
+       * amd/sun_map_parse.y: instead of using a custom FOO_alloc()
+       function, use Amd's CALLOC(struct FOO) macro.
+
+       * amd/sun_map.h: remove extern definitions to functions no longer
+       needed.
+
+       * amd/sun_map.c: removed superfluous *_alloc() functions, some of
+       which caused conflicts with same-named symbols in the parser
+       (since we rename 'yyalloc' to 'sun_map_alloc').
+
        * configure.in: keep AC_INIT on same line, for nightly snapshot
        build script.
 
index acc3f016ae24774a60f822024722ada67d2d328b..fe5c38c9c196cbcfd66dcf3c818abbebd2df83b1 100644 (file)
 #include <sun_map.h>
 
 
-/*
- * Allocate a sun_mmap struct.
- *
- * return - sun_amap* on success, NULL no memory
- */
-struct sun_mmap *
-sun_mmap_alloc(void)
-{
-  struct sun_mmap *retval;
-
-  retval = (struct sun_mmap *) xmalloc(sizeof(struct sun_mmap));
-  memset(retval, 0, sizeof(struct sun_mmap));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_map struct.
- *
- * return - sun_map* on success, NULL no memory
- */
-struct sun_map *
-sun_map_alloc(void)
-{
-  struct sun_map *retval;
-
-  retval = (struct sun_map *) xmalloc(sizeof(struct sun_map));
-  memset(retval, 0, sizeof(struct sun_map));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_entry struct.
- *
- * return - sun_entry* on success, NULL no memory
- */
-struct sun_entry *
-sun_entry_alloc(void)
-{
-  struct sun_entry *retval;
-
-  retval = (struct sun_entry *) xmalloc(sizeof(struct sun_entry));
-  memset(retval, 0, sizeof(struct sun_entry));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_mountpt
- *
- * return - sun_mountpt* on success, NULL no memory
- */
-struct sun_mountpt *
-sun_mountpt_alloc(void)
-{
-  struct sun_mountpt *retval;
-
-  retval = (struct sun_mountpt *) xmalloc(sizeof(struct sun_mountpt));
-  memset(retval, 0, sizeof(struct sun_mountpt));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_location struct.
- *
- * return sun_location* on sucess, NULL no memory
- */
-struct sun_location *
-sun_location_alloc(void)
-{
-  struct sun_location *retval;
-
-  retval = (struct sun_location *) xmalloc(sizeof(struct sun_location));
-  memset(retval, 0, sizeof(struct sun_location));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_host struct.
- *
- * return sun_host* on sucess, NULL no memory
- */
-struct sun_host *
-sun_host_alloc(void)
-{
-  struct sun_host *retval;
-  retval = (struct sun_host *) xmalloc(sizeof(struct sun_host));
-
-  memset(retval, 0, sizeof(struct sun_host));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_opt struct.
- *
- * return sun_opt* on sucess, NULL no memory
- */
-struct sun_opt *
-sun_opt_alloc(void)
-{
-  struct sun_opt *retval;
-
-  retval = (struct sun_opt *) xmalloc(sizeof(struct sun_opt));
-  memset(retval, 0, sizeof(struct sun_opt));
-
-  return retval;
-}
-
-
-/*
- * Allocate a sun_list struct.
- *
- * return sun_list* on sucess, NULL no memory
- */
-struct sun_list *
-sun_list_alloc(void)
-{
-  struct sun_list *retval;
-
-  retval = (struct sun_list *) xmalloc(sizeof(struct sun_list));
-  memset(retval, 0, sizeof(struct sun_list));
-
-  return retval;
-}
-
 
 /*
  * Add a data pointer to the end of the list.
@@ -360,7 +225,7 @@ sun_entry2amd(const char *a_entry)
     }
   }
   else {
-    plog(XLOG_INFO,"No SUN fstype specified defaulting to NFS.");
+    plog(XLOG_INFO, "No SUN fstype specified defaulting to NFS.");
   }
 
 
index de6a9f07fbe730a90d760bb29e77d4487d08876f..76a088004334c9a391655c00d33735bc22b831c5 100644 (file)
@@ -112,15 +112,7 @@ struct sun_list {
  * EXTERNS
  */
 extern char *sun_entry2amd(const char *);
-extern struct sun_entry *sun_entry_alloc(void);
 extern struct sun_entry *sun_map_parse_read(const char *);
-extern struct sun_host *sun_host_alloc(void);
-extern struct sun_list *sun_list_alloc(void);
-extern struct sun_location *sun_location_alloc(void);
-extern struct sun_map *sun_map_alloc(void);
-extern struct sun_mmap *sun_mmap_alloc(void);
-extern struct sun_mountpt *sun_mountpt_alloc(void);
-extern struct sun_opt *sun_opt_alloc(void);
 extern void sun_list_add(struct sun_list *, qelem *);
 
 #endif /* not _SUN_MAP_H */
index c420179cb1df80b6fff603ff76f3d8b19d99357e..bf8bdb750244be591efd3c3e480dd145f9815b17 100644 (file)
@@ -111,7 +111,7 @@ entry : locations {
   struct sun_entry *entry;
 
   /* allocate an entry */
-  entry = sun_entry_alloc();
+  entry = CALLOC(struct sun_entry);
 
   /*
    * Assign the global location list to this entry and reset the
@@ -131,7 +131,7 @@ entry : locations {
   struct sun_list *list;
   struct sun_entry *entry;
 
-  entry = sun_entry_alloc();
+  entry = CALLOC(struct sun_entry);
 
   /* An fstype may have been defined in the 'options'. */
   if(tmpFsType != NULL) {
@@ -167,7 +167,7 @@ entry : locations {
   struct sun_entry *entry;
 
   /* allocate an entry */
-  entry = sun_entry_alloc();
+  entry = CALLOC(struct sun_entry);
 
   /*
    * Assign the global mountpt list to this entry and reset the global
@@ -188,7 +188,7 @@ entry : locations {
   struct sun_entry *entry;
 
   /* allocate an entry */
-  entry = sun_entry_alloc();
+  entry = CALLOC(struct sun_entry);
 
   /* An fstype may have been defined in the 'options'. */
   if(tmpFsType != NULL) {
@@ -220,7 +220,7 @@ entry : locations {
 
 | '+' WORD {
 
-  struct sun_opt *include = sun_opt_alloc();
+  struct sun_opt *include = CALLOC(struct sun_opt);
   include->str = strdup($2);
 
   sun_list_add(get_sun_include_list(),(qelem *)include);
@@ -237,7 +237,7 @@ mountpoint : WORD WSPACE location {
   struct sun_mountpt *mountpt;
 
   /* allocate a mountpt */
-  mountpt = sun_mountpt_alloc();
+  mountpt = CALLOC(struct sun_mountpt);
 
   /*
    * Assign the global loaction list to this entry and reset the
@@ -260,7 +260,7 @@ mountpoint : WORD WSPACE location {
   struct sun_mountpt *mountpt;
 
   /* allocate a mountpt */
-  mountpt = sun_mountpt_alloc();
+  mountpt = CALLOC(struct sun_mountpt);
 
   /*
    * Assign the global loaction list to this entry and reset the
@@ -297,7 +297,7 @@ location : hosts ':' WORD {
   struct sun_location *location;
 
   /* allocate a new location */
-  location = sun_location_alloc();
+  location = CALLOC(struct sun_location);
 
   /*
    * Assign the global opt list to this entry and reset the global
@@ -319,7 +319,7 @@ location : hosts ':' WORD {
   struct sun_location *location;
 
   /* allocate a new location */
-  location = sun_location_alloc();
+  location = CALLOC(struct sun_location);
 
   location->path = strdup($2);
 
@@ -335,7 +335,7 @@ hosts : host
 host : WORD {
 
   /* allocate a new host */
-  struct sun_host *host = sun_host_alloc();
+  struct sun_host *host = CALLOC(struct sun_host);
 
   host->name = strdup($1);
 
@@ -360,7 +360,7 @@ weight : '(' WORD ')' {
 
   int val;
   /* allocate a new host */
-  struct sun_host *host = sun_host_alloc();
+  struct sun_host *host = CALLOC(struct sun_host);
 
   val = atoi($2);
 
@@ -384,7 +384,7 @@ option : "fstype=" WORD {
 /* all other fs options */
 | WORD {
 
-  struct sun_opt *opt = sun_opt_alloc();
+  struct sun_opt *opt = CALLOC(struct sun_opt);
   opt->str = strdup($1);
 
   /* Add this opt to the opt list. */
@@ -422,7 +422,7 @@ static struct sun_list *
 get_sun_include_list(void)
 {
   if (sun_include_list == NULL) {
-    sun_include_list = sun_list_alloc();
+    sun_include_list = CALLOC(struct sun_list);
   }
   return sun_include_list;
 }
@@ -432,7 +432,7 @@ static struct sun_list *
 get_sun_entry_list(void)
 {
   if (sun_entry_list == NULL) {
-    sun_entry_list = sun_list_alloc();
+    sun_entry_list = CALLOC(struct sun_list);
   }
   return sun_entry_list;
 }
@@ -442,7 +442,7 @@ static struct sun_list *
 get_mountpt_list(void)
 {
   if (mountpt_list == NULL) {
-    mountpt_list = sun_list_alloc();
+    mountpt_list = CALLOC(struct sun_list);
   }
   return mountpt_list;
 }
@@ -452,7 +452,7 @@ static struct sun_list *
 get_sun_location_list(void)
 {
   if (sun_location_list == NULL) {
-    sun_location_list = sun_list_alloc();
+    sun_location_list = CALLOC(struct sun_list);
   }
   return sun_location_list;
 }
@@ -462,7 +462,7 @@ static struct sun_list *
 get_sun_host_list(void)
 {
   if (sun_host_list == NULL) {
-    sun_host_list = sun_list_alloc();
+    sun_host_list = CALLOC(struct sun_list);
   }
   return sun_host_list;
 }
@@ -472,7 +472,7 @@ static struct sun_list *
 get_sun_opt_list(void)
 {
   if (sun_opt_list == NULL) {
-    sun_opt_list = sun_list_alloc();
+    sun_opt_list = CALLOC(struct sun_list);
   }
   return sun_opt_list;
 }