mirror of
https://github.com/hexchat/hexchat.git
synced 2024-11-08 12:12:39 +01:00
checksum: Replace GString usage with regular strings
This commit is contained in:
parent
3dc18ff6fb
commit
a01d9ea152
@ -34,17 +34,16 @@ static char version[] = "4.0";
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gboolean send_message;
|
gboolean send_message;
|
||||||
GString *servername;
|
char *servername;
|
||||||
GString *channel;
|
char *channel;
|
||||||
} ChecksumCallbackInfo;
|
} ChecksumCallbackInfo;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_sha256_result (ChecksumCallbackInfo *info, const char *checksum, const char *filename, GError *error)
|
print_sha256_result (ChecksumCallbackInfo *info, const char *checksum, const char *filename, GError *error)
|
||||||
{
|
{
|
||||||
|
|
||||||
// So then we get the next best available channel, since we always want to print at least somewhere, it's fine
|
// So then we get the next best available channel, since we always want to print at least somewhere, it's fine
|
||||||
hexchat_context *ctx = hexchat_find_context(ph, info->servername->str, info->channel->str);
|
hexchat_context *ctx = hexchat_find_context(ph, info->servername, info->channel);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
// before we print a private message to the wrong channel, we exit early
|
// before we print a private message to the wrong channel, we exit early
|
||||||
if (info->send_message) {
|
if (info->send_message) {
|
||||||
@ -52,9 +51,9 @@ print_sha256_result (ChecksumCallbackInfo *info, const char *checksum, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the context isn't found the first time, we search in the server
|
// if the context isn't found the first time, we search in the server
|
||||||
ctx = hexchat_find_context(ph, info->servername->str, NULL);
|
ctx = hexchat_find_context(ph, info->servername, NULL);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
//the second time we exit early, since printing in another server isn't desireable
|
// The second time we exit early, since printing in another server isn't desireable
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,8 +80,8 @@ file_sha256_complete (GFile *file, GAsyncResult *result, gpointer user_data)
|
|||||||
sha256 = g_task_propagate_pointer (G_TASK (result), &error);
|
sha256 = g_task_propagate_pointer (G_TASK (result), &error);
|
||||||
print_sha256_result (callback_info, sha256, filename, error);
|
print_sha256_result (callback_info, sha256, filename, error);
|
||||||
|
|
||||||
g_string_free(callback_info->servername, TRUE);
|
g_free(callback_info->servername);
|
||||||
g_string_free(callback_info->channel, TRUE);
|
g_free(callback_info->channel);
|
||||||
g_free(callback_info);
|
g_free(callback_info);
|
||||||
g_free (sha256);
|
g_free (sha256);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
@ -140,10 +139,8 @@ dccrecv_cb (char *word[], void *userdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChecksumCallbackInfo *callback_data = g_new (ChecksumCallbackInfo, 1);
|
ChecksumCallbackInfo *callback_data = g_new (ChecksumCallbackInfo, 1);
|
||||||
const char* servername = hexchat_get_info(ph, "server");
|
callback_data->servername = g_strdup(hexchat_get_info(ph, "server"));
|
||||||
callback_data->servername = !servername ? NULL : g_string_new(servername);
|
callback_data->channel = g_strdup(hexchat_get_info(ph, "channel"));
|
||||||
const char *channel = hexchat_get_info(ph, "channel");
|
|
||||||
callback_data->channel = !channel ? NULL : g_string_new(channel);
|
|
||||||
callback_data->send_message = FALSE;
|
callback_data->send_message = FALSE;
|
||||||
|
|
||||||
|
|
||||||
@ -167,10 +164,8 @@ dccoffer_cb (char *word[], void *userdata)
|
|||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
ChecksumCallbackInfo *callback_data = g_new (ChecksumCallbackInfo, 1);
|
ChecksumCallbackInfo *callback_data = g_new (ChecksumCallbackInfo, 1);
|
||||||
const char* servername = hexchat_get_info(ph, "server");
|
callback_data->servername = g_strdup(hexchat_get_info(ph, "server"));
|
||||||
callback_data->servername = !servername ? NULL : g_string_new(servername);
|
callback_data->channel = g_strdup(hexchat_get_info(ph, "channel"));
|
||||||
const char *channel = hexchat_get_info(ph, "channel");
|
|
||||||
callback_data->channel = !channel ? NULL : g_string_new(channel);
|
|
||||||
callback_data->send_message = TRUE;
|
callback_data->send_message = TRUE;
|
||||||
|
|
||||||
filename = g_strdup (word[3]);
|
filename = g_strdup (word[3]);
|
||||||
|
Loading…
Reference in New Issue
Block a user