[gmime: 1/2] Use GChecksum instead of a custom MD5Context
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 1/2] Use GChecksum instead of a custom MD5Context
- Date: Tue, 21 Mar 2017 13:09:42 +0000 (UTC)
commit 6a35aab65ebb7deef4f86bdb01dc86286a45c068
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Tue Mar 21 09:08:44 2017 -0400
Use GChecksum instead of a custom MD5Context
gmime/gmime-filter-md5.c | 24 ++--
gmime/gmime-filter-md5.h | 4 +-
util/Makefile.am | 2 -
util/md5-utils.c | 355 ----------------------------------------------
util/md5-utils.h | 54 -------
5 files changed, 11 insertions(+), 428 deletions(-)
---
diff --git a/gmime/gmime-filter-md5.c b/gmime/gmime-filter-md5.c
index f380e14..9df77d5 100644
--- a/gmime/gmime-filter-md5.c
+++ b/gmime/gmime-filter-md5.c
@@ -23,8 +23,6 @@
#include <config.h>
#endif
-#include "md5-utils.h"
-
#include "gmime-filter-md5.h"
@@ -37,11 +35,6 @@
* Calculate an md5sum for a stream.
**/
-
-struct _GMimeFilterMd5Private {
- MD5Context md5;
-};
-
static void g_mime_filter_md5_class_init (GMimeFilterMd5Class *klass);
static void g_mime_filter_md5_init (GMimeFilterMd5 *filter, GMimeFilterMd5Class *klass);
static void g_mime_filter_md5_finalize (GObject *object);
@@ -101,8 +94,7 @@ g_mime_filter_md5_class_init (GMimeFilterMd5Class *klass)
static void
g_mime_filter_md5_init (GMimeFilterMd5 *filter, GMimeFilterMd5Class *klass)
{
- filter->priv = g_new (struct _GMimeFilterMd5Private, 1);
- md5_init (&filter->priv->md5);
+ filter->md5 = g_checksum_new (G_CHECKSUM_MD5);
}
static void
@@ -110,7 +102,7 @@ g_mime_filter_md5_finalize (GObject *object)
{
GMimeFilterMd5 *filter = (GMimeFilterMd5 *) object;
- g_free (filter->priv);
+ g_checksum_free (filter->md5);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -127,9 +119,9 @@ static void
filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace)
{
- GMimeFilterMd5 *md5 = (GMimeFilterMd5 *) filter;
+ GChecksum *md5 = ((GMimeFilterMd5 *) filter)->md5;
- md5_update (&md5->priv->md5, (unsigned char *) in, len);
+ g_checksum_update (md5, (unsigned char *) in, len);
*out = in;
*outlen = len;
@@ -146,9 +138,9 @@ filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
static void
filter_reset (GMimeFilter *filter)
{
- GMimeFilterMd5 *md5 = (GMimeFilterMd5 *) filter;
+ GChecksum *md5 = ((GMimeFilterMd5 *) filter)->md5;
- md5_init (&md5->priv->md5);
+ g_checksum_reset (md5);
}
@@ -176,7 +168,9 @@ g_mime_filter_md5_new (void)
void
g_mime_filter_md5_get_digest (GMimeFilterMd5 *md5, unsigned char digest[16])
{
+ gsize len = 16;
+
g_return_if_fail (GMIME_IS_FILTER_MD5 (md5));
- md5_final (&md5->priv->md5, digest);
+ g_checksum_get_digest (md5->md5, digest, &len);
}
diff --git a/gmime/gmime-filter-md5.h b/gmime/gmime-filter-md5.h
index b825326..d40480c 100644
--- a/gmime/gmime-filter-md5.h
+++ b/gmime/gmime-filter-md5.h
@@ -39,14 +39,14 @@ typedef struct _GMimeFilterMd5Class GMimeFilterMd5Class;
/**
* GMimeFilterMd5:
* @parent_object: parent #GMimeFilter
- * @priv: private state data
+ * @md5: The MD5 checksum context
*
* A filter for calculating the MD5 checksum of a stream.
**/
struct _GMimeFilterMd5 {
GMimeFilter parent_object;
- struct _GMimeFilterMd5Private *priv;
+ GChecksum *md5;
};
struct _GMimeFilterMd5Class {
diff --git a/util/Makefile.am b/util/Makefile.am
index 37535c4..16cb00b 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -17,8 +17,6 @@ libutil_la_SOURCES = \
gtrie.h \
list.c \
list.h \
- md5-utils.c \
- md5-utils.h \
packed.c \
packed.h \
url-scanner.c \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]