svn commit: samba r7701 - in branches/SAMBA_3_0/source/wrepld: .

jra at samba.org jra at samba.org
Fri Jun 17 20:32:33 GMT 2005


Author: jra
Date: 2005-06-17 20:32:33 +0000 (Fri, 17 Jun 2005)
New Revision: 7701

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

Log:
Patch from James Peach | jpeach at sgi.com to make wrepld use new
talloc interfaces.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/wrepld/parser.c
   branches/SAMBA_3_0/source/wrepld/process.c
   branches/SAMBA_3_0/source/wrepld/server.c


Changeset:
Modified: branches/SAMBA_3_0/source/wrepld/parser.c
===================================================================
--- branches/SAMBA_3_0/source/wrepld/parser.c	2005-06-17 20:32:13 UTC (rev 7700)
+++ branches/SAMBA_3_0/source/wrepld/parser.c	2005-06-17 20:32:33 UTC (rev 7701)
@@ -37,7 +37,7 @@
 		more=256;
 
 	if (buffer->offset+more >= buffer->length) {
-		temp=(char *)talloc_realloc(mem_ctx, buffer->buffer, sizeof(char)* (buffer->length+more) );
+		temp=talloc_realloc(mem_ctx, buffer->buffer, char, buffer->length + more);
 		if (temp==NULL) {
 			DEBUG(0,("grow_buffer: can't grow buffer\n"));
 			return False;
@@ -141,7 +141,7 @@
 	outbuf->offset+=4;
 
 	if (wins_name->name_flag & 2) {
-		wins_name->others=(struct in_addr *)talloc(mem_ctx, sizeof(struct in_addr)*wins_name->num_ip);
+		wins_name->others=talloc_array(mem_ctx, struct in_addr, wins_name->num_ip);
 		if (wins_name->others==NULL)
 			return;
 
@@ -172,7 +172,7 @@
 	un_rq->partner_count=RIVAL(inbuf->buffer, inbuf->offset);
 	inbuf->offset+=4;
 
-	un_rq->wins_owner=(WINS_OWNER *)talloc(mem_ctx, un_rq->partner_count*sizeof(WINS_OWNER));
+	un_rq->wins_owner=talloc_array(mem_ctx, WINS_OWNER, un_rq->partner_count);
 	if (un_rq->wins_owner==NULL)
 		return;
 
@@ -205,7 +205,7 @@
 	se_rp->max_names = RIVAL(inbuf->buffer, inbuf->offset);
 	inbuf->offset+=4;
 
-	se_rp->wins_name=(WINS_NAME *)talloc(mem_ctx, se_rp->max_names*sizeof(WINS_NAME));
+	se_rp->wins_name=talloc_array(mem_ctx, WINS_NAME, se_rp->max_names);
 	if (se_rp->wins_name==NULL)
 		return;
 
@@ -226,7 +226,7 @@
 	avmt_rep->partner_count=RIVAL(inbuf->buffer, inbuf->offset);
 	inbuf->offset+=4;
 
-	avmt_rep->wins_owner=(WINS_OWNER *)talloc(mem_ctx, avmt_rep->partner_count*sizeof(WINS_OWNER));
+	avmt_rep->wins_owner=talloc_array(mem_ctx, WINS_OWNER, avmt_rep->partner_count);
 	if (avmt_rep->wins_owner==NULL)
 		return;
 

Modified: branches/SAMBA_3_0/source/wrepld/process.c
===================================================================
--- branches/SAMBA_3_0/source/wrepld/process.c	2005-06-17 20:32:13 UTC (rev 7700)
+++ branches/SAMBA_3_0/source/wrepld/process.c	2005-06-17 20:32:33 UTC (rev 7701)
@@ -126,7 +126,7 @@
 		r->rep.msg_type=MESSAGE_REP_UPDATE_NOTIFY_REQUEST;
 		r->rep.un_rq.partner_count=partner_count;
 		
-		r->rep.un_rq.wins_owner=(WINS_OWNER *)talloc(mem_ctx, partner_count*sizeof(WINS_OWNER));
+		r->rep.un_rq.wins_owner=talloc_array(mem_ctx, WINS_OWNER, partner_count);
 		if (r->rep.un_rq.wins_owner==NULL) {
 			DEBUG(0,("start_assoc_reply: can't alloc memory\n"));
 			stop_packet(q, r, STOP_REASON_USER_REASON);
@@ -238,7 +238,7 @@
 	 */ 
 	get_our_last_id(&global_wins_table[0][0]);
 
-	r->rep.avmt_rep.wins_owner=(WINS_OWNER *)talloc(mem_ctx, partner_count*sizeof(WINS_OWNER));
+	r->rep.avmt_rep.wins_owner=talloc_array(mem_ctx, WINS_OWNER, partner_count);
 	if (r->rep.avmt_rep.wins_owner==NULL) {
 		stop_packet(q, r, STOP_REASON_USER_REASON);
 		return;
@@ -407,7 +407,7 @@
 	int i;
 	int current=*max_names;
 
-	temp_list=talloc_realloc(mem_ctx, *wins_name, (current+1)*sizeof(WINS_NAME));
+	temp_list=talloc_realloc(mem_ctx, *wins_name, WINS_NAME, current + 1);
 	if (temp_list==NULL)
 		return False;
 
@@ -431,7 +431,7 @@
 
 	if (temp_list[current].name_flag & 2) {
 		temp_list[current].num_ip=num_ips;
-		temp_list[current].others=(struct in_addr *)talloc(mem_ctx, sizeof(struct in_addr)*num_ips);
+		temp_list[current].others=talloc_array(mem_ctx, struct in_addr, num_ips);
 		if (temp_list[current].others==NULL)
 			return False;
 	
@@ -540,7 +540,7 @@
 		wins_ip=*interpret_addr2(ip_str);
 
  		/* Allocate the space for the ip_list. */
-		if((ip_list = (struct in_addr *)talloc(mem_ctx,  num_ips * sizeof(struct in_addr))) == NULL) {
+		if((ip_list = talloc_array(mem_ctx, struct in_addr, num_ips)) == NULL) {
 			SAFE_FREE(dbuf.dptr);
 			DEBUG(0,("initialise_wins: talloc fail !\n"));
 			return;

Modified: branches/SAMBA_3_0/source/wrepld/server.c
===================================================================
--- branches/SAMBA_3_0/source/wrepld/server.c	2005-06-17 20:32:13 UTC (rev 7700)
+++ branches/SAMBA_3_0/source/wrepld/server.c	2005-06-17 20:32:33 UTC (rev 7701)
@@ -295,8 +295,8 @@
 		total += ret;
 	}
 
-	q = (GENERIC_PACKET *)talloc(mem_ctx, sizeof(GENERIC_PACKET));
-	p = (struct wins_packet_struct *)talloc(mem_ctx, sizeof(*p));
+	q = talloc(mem_ctx, GENERIC_PACKET);
+	p = talloc(mem_ctx, struct wins_packet_struct);
 	if (q==NULL || p==NULL)
 		return NULL;
 
@@ -486,7 +486,7 @@
 		}
 
 		/* free temp memory */
-		talloc_destroy_pool(mem_ctx);
+		talloc_free_children(mem_ctx);
 
 		/* free up temp memory */
 		lp_talloc_free();



More information about the samba-cvs mailing list