- Timestamp:
- 2018-07-12T08:42:45Z (6 years ago)
- Parents:
- b9d1fdc
- git-author:
- dequis <dx@…> (12-07-18 08:30:59)
- git-committer:
- dequis <dx@…> (12-07-18 08:42:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
rb9d1fdc r7de07a0 62 62 irc->iconv = (GIConv) - 1; 63 63 irc->oconv = (GIConv) - 1; 64 65 irc->sendbuffer = g_string_sized_new(IRC_MAX_LINE * 2); 64 66 65 67 if (global.conf->ping_interval > 0 && global.conf->ping_timeout > 0) { … … 305 307 } 306 308 307 g_ free(irc->sendbuffer);309 g_string_free(irc->sendbuffer, TRUE); 308 310 g_free(irc->readbuffer); 309 311 g_free(irc->password); … … 595 597 596 598 if (now) { 597 g_free(irc->sendbuffer); 598 irc->sendbuffer = g_strdup("\r\n"); 599 g_string_assign(irc->sendbuffer, "\r\n"); 599 600 } 600 601 irc_vawrite(temp->data, format, params); … … 611 612 void irc_vawrite(irc_t *irc, char *format, va_list params) 612 613 { 613 int size;614 614 char line[IRC_MAX_LINE + 1]; 615 615 … … 638 638 g_strlcat(line, "\r\n", IRC_MAX_LINE + 1); 639 639 640 if (irc->sendbuffer != NULL) { 641 gsize line_len = strlen(line); 642 gsize buffer_len = strlen(irc->sendbuffer); 643 644 size = buffer_len + line_len; 645 irc->sendbuffer = g_renew(char, irc->sendbuffer, size + 1); 646 strcpy((irc->sendbuffer + buffer_len), line); 647 } else { 648 irc->sendbuffer = g_strdup(line); 649 } 640 g_string_append(irc->sendbuffer, line); 650 641 651 642 if (irc->w_watch_source_id == 0) { … … 669 660 { 670 661 ssize_t n; 671 size_t len ;672 673 if ( irc->sendbuffer == NULL) {662 size_t len = irc->sendbuffer->len; 663 664 if (len == 0) { 674 665 return; 675 666 } 676 667 677 len = strlen(irc->sendbuffer); 678 if ((n = send(irc->fd, irc->sendbuffer, len, 0)) == len) { 679 g_free(irc->sendbuffer); 680 irc->sendbuffer = NULL; 668 if ((n = send(irc->fd, irc->sendbuffer->str, len, 0)) == len) { 669 g_string_truncate(irc->sendbuffer, 0); 681 670 682 671 b_event_remove(irc->w_watch_source_id); 683 672 irc->w_watch_source_id = 0; 684 673 } else if (n > 0) { 685 char *s = g_strdup(irc->sendbuffer + n); 686 g_free(irc->sendbuffer); 687 irc->sendbuffer = s; 674 g_string_erase(irc->sendbuffer, 0, n); 688 675 } 689 676 /* Otherwise something went wrong and we don't currently care … … 702 689 b_event_remove(irc->w_watch_source_id); 703 690 irc->w_watch_source_id = 0; 704 g_free(irc->sendbuffer); 705 irc->sendbuffer = NULL; 691 g_string_truncate(irc->sendbuffer, 0); 706 692 } 707 693
Note: See TracChangeset
for help on using the changeset viewer.