# HG changeset patch # User Mark Doliner # Date 1072652817 0 # Node ID 746404b12236d9edc1fd79b29826b206db94d257 # Parent 4eb96e3cf633380db744e7a71bf8f3eac350d3c3 [gaim-migrate @ 8621] I removed some more of those dumb allocations. This also fixes a problem with changing the text of outgoing messages from a perl script, and I guess from C and tcl, also. Basically, before this change, if you editing a message from a script, your changes would get sent to the other person, but the old message would still get shown to the Gaim user. committer: Tailor Script diff -r 4eb96e3cf633 -r 746404b12236 src/conversation.c --- a/src/conversation.c Sun Dec 28 22:25:18 2003 +0000 +++ b/src/conversation.c Sun Dec 28 23:06:57 2003 +0000 @@ -183,12 +183,14 @@ GaimConversationType type; GaimConnection *gc; GaimConversationUiOps *ops; - char *buf, *buf2, *buffy = NULL; + char *buffy = NULL; int plugin_return; - int limit; int err = 0; GList *first; + if (strlen(message) == 0) + return; + gc = gaim_conversation_get_gc(conv); g_return_if_fail(gc != NULL); @@ -196,36 +198,22 @@ type = gaim_conversation_get_type(conv); ops = gaim_conversation_get_ui_ops(conv); - limit = 32 * 1024; /* You shouldn't be sending more than 32K in your - messages. That's a book. */ - - buf = g_malloc(limit); - strncpy(buf, message, limit); - - if (strlen(buf) == 0) { - g_free(buf); - - return; - } - first = g_list_first(conv->send_history); if (first->data) g_free(first->data); - first->data = g_strdup(buf); + first->data = g_strdup(message); conv->send_history = g_list_prepend(first, NULL); - buf2 = g_malloc(limit); - if ((gc->flags & GAIM_CONNECTION_HTML) && gaim_prefs_get_bool("/core/conversations/send_urls_as_links")) { - buffy = gaim_markup_linkify(buf); + buffy = gaim_markup_linkify(message); } else - buffy = g_strdup(buf); + buffy = g_strdup(message); plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( @@ -234,22 +222,14 @@ ? "displaying-im-msg" : "displaying-chat-msg"), gaim_conversation_get_account(conv), conv, &buffy)); - if (buffy == NULL) { - g_free(buf2); - g_free(buf); + if (buffy == NULL) return; - } if (plugin_return) { g_free(buffy); - g_free(buf2); - g_free(buf); return; } - strncpy(buf, buffy, limit); - g_free(buffy); - gaim_signal_emit(gaim_conversations_get_handle(), (type == GAIM_CONV_IM ? "displayed-im-msg" : "displayed-chat-msg"), gaim_conversation_get_account(conv), conv, buffy); @@ -257,12 +237,11 @@ if (type == GAIM_CONV_IM) { GaimConvIm *im = GAIM_CONV_IM(conv); - buffy = g_strdup(buf); gaim_signal_emit(gaim_conversations_get_handle(), "sending-im-msg", gaim_conversation_get_account(conv), gaim_conversation_get_name(conv), &buffy); - if (buffy != NULL) { + if (buffy != NULL && buffy[0] != '\0') { GaimConvImFlags imflags = 0; GaimMessageFlags msgflags = GAIM_MESSAGE_SEND; @@ -275,7 +254,7 @@ buffy, imflags); if (err > 0) - gaim_conv_im_write(im, NULL, buf, msgflags, time(NULL)); + gaim_conv_im_write(im, NULL, buffy, msgflags, time(NULL)); if (im->images != NULL) { GSList *tempy; @@ -296,31 +275,22 @@ gaim_signal_emit(gaim_conversations_get_handle(), "sent-im-msg", gaim_conversation_get_account(conv), gaim_conversation_get_name(conv), buffy); - - g_free(buffy); } } else { - buffy = g_strdup(buf); - gaim_signal_emit(gaim_conversations_get_handle(), "sending-chat-msg", gaim_conversation_get_account(conv), &buffy, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); - if (buffy != NULL) { + if (buffy != NULL && buffy[0] != '\0') { err = serv_chat_send(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), buffy); gaim_signal_emit(gaim_conversations_get_handle(), "sent-chat-msg", - gaim_conversation_get_account(conv), buf, + gaim_conversation_get_account(conv), buffy, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); - - g_free(buffy); } } - g_free(buf2); - g_free(buf); - if (err < 0) { if (err == -E2BIG) { gaim_notify_error(NULL, NULL,