svn commit: samba r4058 - in branches/SAMBA_4_0/source: include lib lib/registry/tools libads param rpc_server/echo

tridge at samba.org tridge at samba.org
Sat Dec 4 09:30:38 GMT 2004


Author: tridge
Date: 2004-12-04 09:30:38 +0000 (Sat, 04 Dec 2004)
New Revision: 4058

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4058

Log:
added a type safe version of smb_xmalloc()

Modified:
   branches/SAMBA_4_0/source/include/includes.h
   branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c
   branches/SAMBA_4_0/source/lib/util_pw.c
   branches/SAMBA_4_0/source/libads/ads_struct.c
   branches/SAMBA_4_0/source/param/loadparm.c
   branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c


Changeset:
Modified: branches/SAMBA_4_0/source/include/includes.h
===================================================================
--- branches/SAMBA_4_0/source/include/includes.h	2004-12-04 00:14:47 UTC (rev 4057)
+++ branches/SAMBA_4_0/source/include/includes.h	2004-12-04 09:30:38 UTC (rev 4058)
@@ -321,3 +321,8 @@
 
 #endif /* _INCLUDES_H */
 
+/*
+  type safe varient of smb_xmalloc()
+*/
+#define smb_xmalloc_p(type) (type *)smb_xmalloc(sizeof(type))
+

Modified: branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c	2004-12-04 00:14:47 UTC (rev 4057)
+++ branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c	2004-12-04 09:30:38 UTC (rev 4058)
@@ -154,7 +154,7 @@
  */
 static struct cmd_line *get_cmd_line(int fd)
 {
-  struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE));
+  struct cmd_line *cl = smb_xmalloc_p(CMD_LINE);
   int i = 0, rc;
   uint8_t ch;
 
@@ -445,7 +445,7 @@
   struct cmd_line *cl = NULL;
   struct val_spec_list *vl = NULL;
 
-  cmd = (struct command_s *)smb_xmalloc(sizeof(struct command_s));
+  cmd = smb_xmalloc_p(struct command_s);
 
   cmd->cmd = CMD_NONE;
   cmd->key = NULL;
@@ -488,7 +488,7 @@
 	 * There could be a \ on the end which we need to 
 	 * handle at some time
 	 */
-	vl = (struct val_spec_list *)smb_xmalloc(sizeof(struct val_spec_list));
+	vl = smb_xmalloc_p(struct val_spec_list);
 	vl->next = NULL;
 	vl->val = NULL;
 	vl->name = parse_value(cl, &vl->type, &vl->val);
@@ -607,7 +607,7 @@
     return NULL;
   }
 
-  tmp = (CMD_FILE *)smb_xmalloc(sizeof(CMD_FILE)); 
+  tmp = smb_xmalloc_p(CMD_FILE); 
 
   /*
    * Let's fill in some of the fields;

Modified: branches/SAMBA_4_0/source/lib/util_pw.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util_pw.c	2004-12-04 00:14:47 UTC (rev 4057)
+++ branches/SAMBA_4_0/source/lib/util_pw.c	2004-12-04 09:30:38 UTC (rev 4058)
@@ -24,7 +24,7 @@
 
 static struct passwd *alloc_copy_passwd(const struct passwd *from) 
 {
-	struct passwd *ret = smb_xmalloc(sizeof(struct passwd));
+	struct passwd *ret = smb_xmalloc_p(struct passwd);
 	ZERO_STRUCTP(ret);
 	ret->pw_name = smb_xstrdup(from->pw_name);
 	ret->pw_passwd = smb_xstrdup(from->pw_passwd);

Modified: branches/SAMBA_4_0/source/libads/ads_struct.c
===================================================================
--- branches/SAMBA_4_0/source/libads/ads_struct.c	2004-12-04 00:14:47 UTC (rev 4057)
+++ branches/SAMBA_4_0/source/libads/ads_struct.c	2004-12-04 09:30:38 UTC (rev 4058)
@@ -87,7 +87,7 @@
 {
 	ADS_STRUCT *ads;
 	
-	ads = (ADS_STRUCT *)smb_xmalloc(sizeof(*ads));
+	ads = smb_xmalloc_p(ADS_STRUCT);
 	ZERO_STRUCTP(ads);
 	
 	ads->server.realm = realm? strdup(realm) : NULL;

Modified: branches/SAMBA_4_0/source/param/loadparm.c
===================================================================
--- branches/SAMBA_4_0/source/param/loadparm.c	2004-12-04 00:14:47 UTC (rev 4057)
+++ branches/SAMBA_4_0/source/param/loadparm.c	2004-12-04 09:30:38 UTC (rev 4058)
@@ -1576,8 +1576,7 @@
 		}
 		else {
 			ServicePtrs = tsp;
-			ServicePtrs[iNumServices] =
-				(service *) malloc(sizeof(service));
+			ServicePtrs[iNumServices] = malloc_p(service);
 		}
 		if (!ServicePtrs[iNumServices]) {
 			DEBUG(0,("add_a_service: out of memory!\n"));
@@ -1871,7 +1870,7 @@
 			pdata = pdata->next;
 		}
 		if (not_added) {
-			paramo = smb_xmalloc(sizeof(*paramo));
+			paramo = smb_xmalloc_p(struct param_opt);
 			paramo->key = strdup(data->key);
 			paramo->value = strdup(data->value);
 			DLIST_ADD(pserviceDest->param_opt, paramo);
@@ -1940,7 +1939,7 @@
 	}
 
 	if (!f) {
-		f = (struct file_lists *)malloc(sizeof(file_lists[0]));
+		f = malloc_p(struct file_lists);
 		if (!f)
 			return;
 		f->next = file_lists;
@@ -2247,7 +2246,7 @@
 		}
 	}
 
-	paramo = smb_xmalloc(sizeof(*paramo));
+	paramo = smb_xmalloc_p(struct param_opt);
 	paramo->key = strdup(name);
 	paramo->value = strdup(pszParmValue);
 	paramo->flags = flags;

Modified: branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c	2004-12-04 00:14:47 UTC (rev 4057)
+++ branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c	2004-12-04 09:30:38 UTC (rev 4058)
@@ -70,7 +70,7 @@
 
 static NTSTATUS echo_TestCall2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_TestCall2 *r)
 {
-	r->out.info = talloc(mem_ctx, sizeof(*r->out.info));
+	r->out.info = talloc_p(mem_ctx, union echo_Info);
 	if (!r->out.info) {
 		return NT_STATUS_NO_MEMORY;
 	}



More information about the samba-cvs mailing list