talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 5fea1d0866a2feb58d8ce093e998a2c58f7dc84e
parent d52aded0fccbff2e4933c2efc3c4909f1590a4c8
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date:   Sat, 11 Sep 2021 21:28:13 -0700

match glib allocate and free functions

fix allocate/free mismatches and switch to glib functions

Diffstat:
Msrc/plugins/rssyl/libfeed/feed.c | 5++---
Msrc/plugins/rssyl/libfeed/feeditem.c | 2+-
Msrc/plugins/rssyl/libfeed/feeditemenclosure.c | 2+-
Msrc/plugins/rssyl/libfeed/parser.c | 14++++++--------
Msrc/plugins/rssyl/libfeed/parser_opml.c | 2+-
Msrc/plugins/rssyl/rssyl_cb_menu.c | 2+-
Msrc/plugins/rssyl/rssyl_parse_feed.c | 2+-
Msrc/plugins/rssyl/strutils.c | 4++--
8 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/plugins/rssyl/libfeed/feed.c b/src/plugins/rssyl/libfeed/feed.c @@ -35,8 +35,7 @@ Feed *feed_new(gchar *url) g_return_val_if_fail(url != NULL, NULL); - feed = malloc( sizeof(Feed) ); - g_return_val_if_fail(feed != NULL, NULL); + feed = g_malloc( sizeof(Feed) ); feed->is_valid = TRUE; feed->timeout = FEED_DEFAULT_TIMEOUT; @@ -263,7 +262,7 @@ guint feed_update(Feed *feed, time_t last_update) g_return_val_if_fail(eh != NULL, FEED_ERR_INIT); /* Curl initialized, create parser context now. */ - feed_ctx = malloc( sizeof(FeedParserCtx) ); + feed_ctx = g_malloc( sizeof(FeedParserCtx) ); feed_ctx->parser = XML_ParserCreate(NULL); feed_ctx->depth = 0; diff --git a/src/plugins/rssyl/libfeed/feeditem.c b/src/plugins/rssyl/libfeed/feeditem.c @@ -36,7 +36,7 @@ FeedItem *feed_item_new(Feed *feed) { FeedItem *item = NULL; - item = malloc( sizeof(FeedItem) ); + item = g_malloc( sizeof(FeedItem) ); item->url = NULL; item->title = NULL; item->title_format = 0; diff --git a/src/plugins/rssyl/libfeed/feeditemenclosure.c b/src/plugins/rssyl/libfeed/feeditemenclosure.c @@ -32,7 +32,7 @@ FeedItemEnclosure *feed_item_enclosure_new(gchar *url, gchar *type, gulong size) g_return_val_if_fail(type != NULL, NULL); g_return_val_if_fail(size > 0, NULL); - enclosure = malloc( sizeof(FeedItemEnclosure) ); + enclosure = g_malloc( sizeof(FeedItemEnclosure) ); enclosure->url = g_strdup(url); enclosure->type = g_strdup(type); enclosure->size = size; diff --git a/src/plugins/rssyl/libfeed/parser.c b/src/plugins/rssyl/libfeed/parser.c @@ -120,9 +120,7 @@ void libfeed_expat_chparse(void *data, const gchar *s, gint len) gchar *buf = NULL; gint i, xblank = 1; - buf = malloc(len+1); - strncpy(buf, s, len); - buf[len] = '\0'; + buf = g_strndup(s, len); /* check if the string is blank, ... */ for( i = 0; i < strlen(buf); i++ ) @@ -336,9 +334,9 @@ static void feed_parser_unknown_encoding_data_free(void *data) struct FeedParserUnknownEncoding *enc_data; enc_data = data; - free(enc_data->charset); + g_free(enc_data->charset); g_iconv_close(enc_data->cd); - free(enc_data); + g_free(enc_data); } int feed_parser_unknown_encoding_handler(void *encdata, const XML_Char *name, @@ -360,15 +358,15 @@ int feed_parser_unknown_encoding_handler(void *encdata, const XML_Char *name, if( cd == (GIConv)-1 ) return XML_STATUS_ERROR; - data = malloc( sizeof(*data) ); + data = g_malloc( sizeof(*data) ); if( data == NULL ) { g_iconv_close(cd); return XML_STATUS_ERROR; } - data->charset = strdup(name); + data->charset = g_strdup(name); if( data->charset == NULL ) { - free(data); + g_free(data); g_iconv_close(cd); return XML_STATUS_ERROR; } diff --git a/src/plugins/rssyl/libfeed/parser_opml.c b/src/plugins/rssyl/libfeed/parser_opml.c @@ -85,7 +85,7 @@ void opml_process(gchar *path, OPMLProcessFunc function, gpointer data) gint status, err; /* Initialize our context */ - ctx = malloc( sizeof(OPMLProcessCtx) ); + ctx = g_malloc( sizeof(OPMLProcessCtx) ); ctx->parser = XML_ParserCreate(NULL); ctx->depth = 0; ctx->str = NULL; diff --git a/src/plugins/rssyl/rssyl_cb_menu.c b/src/plugins/rssyl/rssyl_cb_menu.c @@ -365,7 +365,7 @@ void rssyl_import_feed_list_cb(GtkAction *action, gpointer data) g_return_if_fail(item != NULL); g_return_if_fail(item->folder != NULL); - ctx = malloc( sizeof(OPMLImportCtx) ); + ctx = g_malloc( sizeof(OPMLImportCtx) ); ctx->failures = 0; ctx->depth = rssyl_folder_depth(item) + 1; ctx->current = NULL; diff --git a/src/plugins/rssyl/rssyl_parse_feed.c b/src/plugins/rssyl/rssyl_parse_feed.c @@ -96,7 +96,7 @@ static void rssyl_expire_items(RFolderItem *ritem, Feed *feed) g_return_if_fail(ritem->items != NULL); g_return_if_fail(feed != NULL); - ctx = malloc( sizeof(RSSylExpireItemsCtx) ); + ctx = g_malloc( sizeof(RSSylExpireItemsCtx) ); ctx->expired_ids = NULL; /* Check each locally stored item, if it is still in the upstream diff --git a/src/plugins/rssyl/strutils.c b/src/plugins/rssyl/strutils.c @@ -70,7 +70,7 @@ gchar *rssyl_strreplace(gchar *source, gchar *pattern, - ( count * len_pattern ) + ( count * len_replacement ); - new = malloc(final_length + 1); + new = g_malloc(final_length + 1); memset(new, '\0', final_length + 1); /* 'c' will be our iterator over original string @@ -195,7 +195,7 @@ static gchar *rssyl_sanitize_string(gchar *str, gboolean strip_nl) if( str == NULL ) return NULL; - n = new = malloc(strlen(str) + 1); + n = new = g_malloc(strlen(str) + 1); memset(new, '\0', strlen(str) + 1); while( *c != '\0' ) {