--- evolution-2.2.2/addressbook/conduit/address-conduit.c.port-to-pilot-link-0.12	2004-09-23 14:50:17.000000000 -0400
+++ evolution-2.2.2/addressbook/conduit/address-conduit.c	2005-04-30 02:22:44.000000000 -0400
@@ -789,7 +789,7 @@
 			      EAddrConduitContext *ctxt)
 {
 	GnomePilotRecord p;
-	static char record[0xffff];
+	static unsigned char record[0xffff];
 	
 	g_assert (local->addr != NULL );
 	
@@ -832,16 +832,16 @@
 	 */
 	if (local->local.ID != 0) {
 		struct Address addr;
-		char record[0xffff];
+		pi_buffer_t *buffer = pi_buffer_new (0xffff);
 		int cat = 0;
 		
 		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
 					ctxt->dbi->db_handle,
-					local->local.ID, &record, 
-					NULL, NULL, NULL, &cat) > 0) {
+					local->local.ID, buffer, 
+					NULL, NULL, &cat) > 0) {
 			local->local.category = cat;
 			memset (&addr, 0, sizeof (struct Address));
-			unpack_Address (&addr, record, 0xffff);
+			unpack_Address (&addr, buffer->data, 0xffff);
 			for (i = 0; i < 5; i++) {
 				if (addr.entry[entryPhone1 + i])
 					local->addr->entry[entryPhone1 + i] = 
@@ -856,6 +856,8 @@
 			}
 			free_Address (&addr);
 		}
+
+		pi_buffer_free (buffer);
 	}
 
 	local->addr->entry[entryFirstname] = e_pilot_utf8_to_pchar (e_contact_get_const (contact, E_CONTACT_GIVEN_NAME));
@@ -1161,7 +1163,7 @@
 	EBookQuery *query;
     	GList *l;
 	int len;
-	unsigned char *buf;
+	pi_buffer_t *buffer;
 	char *filename;
 	char *change_id;
 	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
@@ -1244,9 +1246,9 @@
   	gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
   	gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
 
-	buf = (unsigned char*)g_malloc (0xffff);
+	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-			      (unsigned char *)buf, 0xffff);
+				0xffff, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's Address application block"));
@@ -1255,8 +1257,8 @@
 					   _("Could not read pilot's Address application block"));
 		return -1;
 	}
-	unpack_AddressAppInfo (&(ctxt->ai), buf, len);
-	g_free (buf);
+	unpack_AddressAppInfo (&(ctxt->ai), buffer->data, len);
+	pi_buffer_free (buffer);
 
   	check_for_slow_setting (conduit, ctxt);
 	if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
--- evolution-2.2.2/calendar/conduits/calendar/calendar-conduit.c.port-to-pilot-link-0.12	2005-04-30 01:51:32.000000000 -0400
+++ evolution-2.2.2/calendar/conduits/calendar/calendar-conduit.c	2005-04-30 02:15:02.000000000 -0400
@@ -751,7 +751,7 @@
 			      ECalConduitContext *ctxt)
 {
 	GnomePilotRecord p;
-	static char record[0xffff];
+	static unsigned char record[0xffff];
 
 	g_assert (local->comp != NULL);
 	g_assert (local->appt != NULL );
@@ -800,22 +800,24 @@
          * we don't overwrite them 
 	 */
 	if (local->local.ID != 0) {
-		struct Appointment appt;		
-		char record[0xffff];
+		struct Appointment appt;
+		pi_buffer_t *buffer = pi_buffer_new (0xffff);
 		int cat = 0;
 		
 		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
 					ctxt->dbi->db_handle,
-					local->local.ID, &record, 
-					NULL, NULL, NULL, &cat) > 0) {
+					local->local.ID, buffer,
+					NULL, NULL, &cat) > 0) {
 			local->local.category = cat;
 			memset (&appt, 0, sizeof (struct Appointment));
-			unpack_Appointment (&appt, record, 0xffff);
+			unpack_Appointment (&appt, buffer->data, 0xffff);
 			local->appt->alarm = appt.alarm;
 			local->appt->advance = appt.advance;
 			local->appt->advanceUnits = appt.advanceUnits;
 			free_Appointment (&appt);
 		}
+
+		pi_buffer_free (buffer);
 	}
 
 	/* STOP: don't replace these with g_strdup, since free_Appointment
@@ -1342,7 +1344,7 @@
 	GnomePilotConduitSyncAbs *abs_conduit;
 	GList *removed = NULL, *added = NULL, *l;
 	int len;
-	unsigned char *buf;
+	pi_buffer_t *buffer;
 	char *filename, *change_id;
 	icalcomponent *icalcomp;
 	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
@@ -1460,9 +1462,9 @@
 	gnome_pilot_conduit_sync_abs_set_num_updated_local_records (abs_conduit, mod_records);
 	gnome_pilot_conduit_sync_abs_set_num_deleted_local_records(abs_conduit, del_records);
 
-	buf = (unsigned char*)g_malloc (0xffff);
+	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-			      (unsigned char *)buf, 0xffff);
+				0xffff, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's Calendar application block"));
@@ -1471,8 +1473,8 @@
 					   _("Could not read pilot's Calendar application block"));
 		return -1;
 	}
-	unpack_AppointmentAppInfo (&(ctxt->ai), buf, len);
-	g_free (buf);
+	unpack_AppointmentAppInfo (&(ctxt->ai), buffer->data, len);
+	pi_buffer_free (buffer);
 
 	check_for_slow_setting (conduit, ctxt);
 	if (ctxt->cfg->sync_type == GnomePilotConduitSyncTypeCopyToPilot
--- evolution-2.2.2/calendar/conduits/todo/todo-conduit.c.port-to-pilot-link-0.12	2005-04-30 02:13:27.000000000 -0400
+++ evolution-2.2.2/calendar/conduits/todo/todo-conduit.c	2005-04-30 02:18:11.000000000 -0400
@@ -594,7 +594,7 @@ local_record_to_pilot_record (EToDoLocal
 			      EToDoConduitContext *ctxt)
 {
 	GnomePilotRecord p;
-	static char record[0xffff];
+	static unsigned char record[0xffff];
 
 	g_assert (local->comp != NULL);
 	g_assert (local->todo != NULL );
@@ -696,15 +696,17 @@ local_record_from_comp (EToDoLocalRecord
 
 	/* Don't overwrite the category */
 	if (local->local.ID != 0) {
-		char record[0xffff];
+		pi_buffer_t *buffer = pi_buffer_new (0xffff);
 		int cat = 0;
 		
 		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
 					ctxt->dbi->db_handle,
-					local->local.ID, &record, 
-					NULL, NULL, NULL, &cat) > 0) {
+					local->local.ID, buffer, 
+					NULL, NULL, &cat) > 0) {
 			local->local.category = cat;
 		}
+
+		pi_buffer_free (buffer);
 	}
 	
 	/*
@@ -1014,7 +1016,7 @@ pre_sync (GnomePilotConduit *conduit,
 	GnomePilotConduitSyncAbs *abs_conduit;
 	GList *l;
 	int len;
-	unsigned char *buf;
+	pi_buffer_t *buffer;
 	char *filename, *change_id;
 	icalcomponent *icalcomp;
 	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
@@ -1104,9 +1106,9 @@ pre_sync (GnomePilotConduit *conduit,
 	g_message("num_records: %d\nadd_records: %d\nmod_records: %d\ndel_records: %d\n",
 			num_records, add_records, mod_records, del_records);
 
-	buf = (unsigned char*)g_malloc (0xffff);
+	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-			      (unsigned char *)buf, 0xffff);
+				0xffff, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's ToDo application block"));
@@ -1115,9 +1117,9 @@ pre_sync (GnomePilotConduit *conduit,
 					   _("Could not read pilot's ToDo application block"));
 		return -1;
 	}
-	unpack_ToDoAppInfo (&(ctxt->ai), buf, len);
-	g_free (buf);
-	
+	unpack_ToDoAppInfo (&(ctxt->ai), buffer->data, len);
+	pi_buffer_free (buffer);
+
 	lastDesktopUniqueID = 128;
 
 	check_for_slow_setting (conduit, ctxt);
--- evolution/calendar/conduits/memo/memo-conduit.c	2005-10-19 17:09:35.000000000 +0530
+++ evolution-2.5.5.1/calendar/conduits/memo/memo-conduit.c	2006-01-20 02:31:15.000000000 +0530
@@ -451,7 +451,7 @@ local_record_to_pilot_record (EMemoLocal
 			      EMemoConduitContext *ctxt)
 {
 	GnomePilotRecord p;
-	static char record[0xffff];
+	static unsigned char record[0xffff];
 
 	g_assert (local->comp != NULL);
 	g_assert (local->memo != NULL );
@@ -568,17 +568,18 @@ local_record_from_comp (EMemoLocalRecord
 
 	/* Don't overwrite the category */
 	if (local->local.ID != 0) {
-		char record[0xffff];
+		pi_buffer_t *buffer = pi_buffer_new (0xffff);
 		int cat = 0;
 		
 		LOG(fprintf(stderr, "local_record_from_comp: calling dlp_ReadRecordById\n"));
 		if (dlp_ReadRecordById (ctxt->dbi->pilot_socket, 
 					ctxt->dbi->db_handle,
-					local->local.ID, &record, 
-					NULL, NULL, NULL, &cat) > 0) {
+					local->local.ID, buffer, 
+					NULL, NULL, &cat) > 0) {
 			local->local.category = cat;
 		}
 		LOG(fprintf(stderr, "local_record_from_comp: done calling dlp_ReadRecordById\n"));
+		pi_buffer_free (buffer);
 	}
 	
 	/*
@@ -836,7 +837,7 @@ pre_sync (GnomePilotConduit *conduit,
 	GnomePilotConduitSyncAbs *abs_conduit;
 	GList *l;
 	int len;
-	unsigned char *buf;
+	pi_buffer_t *buffer;
 	char *filename, *change_id;
 	icalcomponent *icalcomp;
 	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
@@ -929,9 +930,9 @@ pre_sync (GnomePilotConduit *conduit,
 	g_message("num_records: %d\nadd_records: %d\nmod_records: %d\ndel_records: %d\n",
 		num_records, add_records, mod_records, del_records);
 
-	buf = (unsigned char*)g_malloc (0xffff);
+	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-			      (unsigned char *)buf, 0xffff);
+				0xffff, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's Memo application block"));
@@ -940,8 +941,8 @@ pre_sync (GnomePilotConduit *conduit,
 					   _("Could not read pilot's Memo application block"));
 		return -1;
 	}
-	unpack_MemoAppInfo (&(ctxt->ai), buf, len);
-	g_free (buf);
+	unpack_MemoAppInfo (&(ctxt->ai), buffer->data, len);
+	pi_buffer_free (buffer);
 	
 	lastDesktopUniqueID = 128;