comparison src/core.c @ 4817:b4ca2cc6bed9

[gaim-migrate @ 5141] <LSchiere> Paco-Paco: commit message? <Paco-Paco> I forget <Paco-Paco> let me look <Paco-Paco> initialize GError pointers properly committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 18 Mar 2003 03:03:58 +0000
parents 4af15fbcb00a
children fefad67de2c7
comparison
equal deleted inserted replaced
4816:94e75b03c598 4817:b4ca2cc6bed9
94 return buffer; 94 return buffer;
95 } 95 }
96 96
97 gint UI_write(struct UI *ui, guchar *data, gint len) 97 gint UI_write(struct UI *ui, guchar *data, gint len)
98 { 98 {
99 GError *error; 99 GError *error = NULL;
100 gint sent; 100 gint sent;
101 /* we'll let the write silently fail because the read will pick it up as dead */ 101 /* we'll let the write silently fail because the read will pick it up as dead */
102 g_io_channel_write_chars(ui->channel, data, len, &sent, &error); 102 g_io_channel_write_chars(ui->channel, data, len, &sent, &error);
103 g_error_free(error); 103 if (error)
104 g_error_free(error);
104 return sent; 105 return sent;
105 } 106 }
106 107
107 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...) 108 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...)
108 { 109 {
300 301
301 GError *error = NULL; 302 GError *error = NULL;
302 303
303 while (total < len) { 304 while (total < len) {
304 if (g_io_channel_read_chars(source, buf + total, len - total, &cur, &error) != G_IO_STATUS_NORMAL) { 305 if (g_io_channel_read_chars(source, buf + total, len - total, &cur, &error) != G_IO_STATUS_NORMAL) {
305 g_error_free(error); 306 if (error)
307 g_error_free(error);
306 return -1; 308 return -1;
307 } 309 }
308 if (cur == 0) 310 if (cur == 0)
309 return total; 311 return total;
310 total += cur; 312 total += cur;
340 342
341 guchar type; 343 guchar type;
342 guchar subtype; 344 guchar subtype;
343 guint32 len; 345 guint32 len;
344 346
345 GError *error; 347 GError *error = NULL;
346 348
347 guchar *in; 349 guchar *in;
348 350
349 /* no byte order worries! this'll change if we go to TCP */ 351 /* no byte order worries! this'll change if we go to TCP */
350 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { 352 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) {
351 debug_printf("UI has abandoned us!\n"); 353 debug_printf("UI has abandoned us!\n");
352 uis = g_slist_remove(uis, ui); 354 uis = g_slist_remove(uis, ui);
353 g_io_channel_shutdown(ui->channel, TRUE, &error); 355 g_io_channel_shutdown(ui->channel, TRUE, &error);
354 if(error) 356 if(error) {
355 g_error_free(error); 357 g_error_free(error);
358 error = NULL;
359 }
356 g_source_remove(ui->inpa); 360 g_source_remove(ui->inpa);
357 g_free(ui); 361 g_free(ui);
358 return FALSE; 362 return FALSE;
359 } 363 }
360 364
361 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { 365 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) {
362 debug_printf("UI has abandoned us!\n"); 366 debug_printf("UI has abandoned us!\n");
363 uis = g_slist_remove(uis, ui); 367 uis = g_slist_remove(uis, ui);
364 g_io_channel_shutdown(ui->channel, TRUE, &error); 368 g_io_channel_shutdown(ui->channel, TRUE, &error);
365 if(error) 369 if(error) {
366 g_error_free(error); 370 g_error_free(error);
371 error = NULL;
372 }
367 g_source_remove(ui->inpa); 373 g_source_remove(ui->inpa);
368 g_free(ui); 374 g_free(ui);
369 return FALSE; 375 return FALSE;
370 } 376 }
371 377
372 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) { 378 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) {
373 debug_printf("UI has abandoned us!\n"); 379 debug_printf("UI has abandoned us!\n");
374 uis = g_slist_remove(uis, ui); 380 uis = g_slist_remove(uis, ui);
375 g_io_channel_shutdown(ui->channel, TRUE, &error); 381 g_io_channel_shutdown(ui->channel, TRUE, &error);
376 if(error) 382 if(error) {
377 g_error_free(error); 383 g_error_free(error);
384 error = NULL;
385 }
378 g_source_remove(ui->inpa); 386 g_source_remove(ui->inpa);
379 g_free(ui); 387 g_free(ui);
380 return FALSE; 388 return FALSE;
381 } 389 }
382 390
384 in = g_new0(guchar, len); 392 in = g_new0(guchar, len);
385 if (gaim_recv(source, in, len) != len) { 393 if (gaim_recv(source, in, len) != len) {
386 debug_printf("UI has abandoned us!\n"); 394 debug_printf("UI has abandoned us!\n");
387 uis = g_slist_remove(uis, ui); 395 uis = g_slist_remove(uis, ui);
388 g_io_channel_shutdown(ui->channel, TRUE, &error); 396 g_io_channel_shutdown(ui->channel, TRUE, &error);
389 if(error) 397 if(error) {
390 g_error_free(error); 398 g_error_free(error);
399 error = NULL;
400 }
391 g_source_remove(ui->inpa); 401 g_source_remove(ui->inpa);
392 g_free(ui); 402 g_free(ui);
393 return FALSE; 403 return FALSE;
394 } 404 }
395 } else 405 } else