comparison libpurple/protocols/mxit/formcmds.c @ 32507:5d81b452dcc4

Need to make a copy of the data passed to purple_imgstore_add_with_id().
author andrew.victor@mxit.com
date Sat, 03 Sep 2011 15:11:20 +0000
parents 9ad5fcde4af4
children 904686722499
comparison
equal deleted inserted replaced
32506:cadc8dfafbaf 32507:5d81b452dcc4
84 * @param error_message Descriptive error message 84 * @param error_message Descriptive error message
85 */ 85 */
86 static void mxit_cb_ii_returned(PurpleUtilFetchUrlData* url_data, gpointer user_data, const gchar* url_text, gsize len, const gchar* error_message) 86 static void mxit_cb_ii_returned(PurpleUtilFetchUrlData* url_data, gpointer user_data, const gchar* url_text, gsize len, const gchar* error_message)
87 { 87 {
88 struct ii_url_request* iireq = (struct ii_url_request*) user_data; 88 struct ii_url_request* iireq = (struct ii_url_request*) user_data;
89 char* ii_data;
90 int* intptr = NULL; 89 int* intptr = NULL;
91 int id; 90 int id;
92 91
93 #ifdef MXIT_DEBUG_COMMANDS 92 #ifdef MXIT_DEBUG_COMMANDS
94 purple_debug_info(MXIT_PLUGIN_ID, "Inline Image returned from %s\n", iireq->url); 93 purple_debug_info(MXIT_PLUGIN_ID, "Inline Image returned from %s\n", iireq->url);
104 if (g_hash_table_lookup(iireq->mx->session->iimages, iireq->url)) { 103 if (g_hash_table_lookup(iireq->mx->session->iimages, iireq->url)) {
105 /* inline image found in the cache, so we just ignore this reply */ 104 /* inline image found in the cache, so we just ignore this reply */
106 goto done; 105 goto done;
107 } 106 }
108 107
109 /* make a copy of the data */ 108 /* we now have the inline image, store a copy in the imagestore */
110 ii_data = g_malloc(len); 109 id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL);
111 memcpy(ii_data, (const char*) url_text, len);
112
113 /* we now have the inline image, store it in the imagestore */
114 id = purple_imgstore_add_with_id(ii_data, len, NULL);
115 110
116 /* map the inline image id to purple image id */ 111 /* map the inline image id to purple image id */
117 intptr = g_malloc(sizeof(int)); 112 intptr = g_malloc(sizeof(int));
118 *intptr = id; 113 *intptr = id;
119 g_hash_table_insert(iireq->mx->session->iimages, iireq->url, intptr); 114 g_hash_table_insert(iireq->mx->session->iimages, iireq->url, intptr);