diff libpurple/protocols/msn/slpmsg_part.c @ 31491:7b771e6f1142

Change SLP P2P functions to use the new buffer access functions instead of mapping to a struct. I don't mind this since it's limited to just one pair of functions. This means that we don't need to use any packing there. Refs #12856.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 17 Dec 2010 07:49:47 +0000
parents 0d5e038911a7
children f91501dc406e
line wrap: on
line diff
--- a/libpurple/protocols/msn/slpmsg_part.c	Fri Dec 17 07:12:21 2010 +0000
+++ b/libpurple/protocols/msn/slpmsg_part.c	Fri Dec 17 07:49:47 2010 +0000
@@ -60,7 +60,7 @@
 	tmp = data;
 
 	/* Extract the binary SLP header */
-	part->header = msn_p2p_header_from_wire((MsnP2PHeader*)tmp);
+	part->header = msn_p2p_header_from_wire(tmp);
 	tmp += P2P_PACKET_HEADER_SIZE;
 
 	/* Extract the body */
@@ -76,7 +76,7 @@
 
 	/* Extract the footer */
 	if (body_len >= 0) 
-		part->footer = msn_p2p_footer_from_wire((MsnP2PFooter*)tmp);
+		part->footer = msn_p2p_footer_from_wire(tmp);
 
 	return part;
 }
@@ -136,21 +136,21 @@
 
 char *msn_slpmsgpart_serialize(MsnSlpMessagePart *part, size_t *ret_size)
 {
-	MsnP2PHeader *header;
-	MsnP2PFooter *footer;
+	char *header;
+	char *footer;
 	char *base;
 	char *tmp;
 	size_t siz;
 
-	base = g_malloc(P2P_PACKET_HEADER_SIZE + part->size + sizeof(MsnP2PFooter));
+	base = g_malloc(P2P_PACKET_HEADER_SIZE + part->size + P2P_PACKET_FOOTER_SIZE);
 	tmp = base;
 
 	header = msn_p2p_header_to_wire(part->header);
 	footer = msn_p2p_footer_to_wire(part->footer);
 
-	siz = sizeof(MsnP2PHeader);
+	siz = P2P_PACKET_HEADER_SIZE;
 	/* Copy header */
-	memcpy(tmp, (char*)header, siz);
+	memcpy(tmp, header, siz);
 	tmp += siz;
 
 	/* Copy body */
@@ -158,8 +158,8 @@
 	tmp += part->size;
 
 	/* Copy footer */
-	siz = sizeof(MsnP2PFooter);
-	memcpy(tmp, (char*)footer, siz);
+	siz = P2P_PACKET_FOOTER_SIZE;
+	memcpy(tmp, footer, siz);
 	tmp += siz;
 
 	*ret_size = tmp - base;