[PATCH] [SAMBA3] update wrepld to new talloc interfaces

James Peach jpeach at sgi.com
Fri Jun 17 05:54:02 GMT 2005


Hi all,

When the talloc interfaces were updated in svn rev 6595, it appears that
parts of wrepld were let behind.

The attached patch against svn HEAD updated wrepld to the new talloc
interface. Note that it compiles, but is otherwise untested.

-- 
James Peach | jpeach at sgi.com | SGI Australian Software Group
I don't speak for SGI.
-------------- next part --------------
Index: source/wrepld/process.c
===================================================================
--- source/wrepld/process.c	(revision 7671)
+++ source/wrepld/process.c	(working copy)
@@ -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;
Index: source/wrepld/server.c
===================================================================
--- source/wrepld/server.c	(revision 7671)
+++ source/wrepld/server.c	(working copy)
@@ -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();
Index: source/wrepld/parser.c
===================================================================
--- source/wrepld/parser.c	(revision 7671)
+++ source/wrepld/parser.c	(working copy)
@@ -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;
 


More information about the samba-technical mailing list