From d238669ef064e32c45c0d4fbbab2abeed824f4b7 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sat, 17 May 2008 16:53:54 +0000 Subject: [PATCH] New function to reset the state of a GChecksum. (g_checksum_new): Call 2008-05-12 Jeffrey Stedfast * glib/gchecksum.c (g_checksum_reset): New function to reset the state of a GChecksum. (g_checksum_new): Call g_checksum_reset() instead of duplicating code. svn path=/trunk/; revision=6903 --- ChangeLog | 8 ++++++++ glib/gchecksum.c | 21 ++++++++++++++++++--- glib/gchecksum.h | 1 + 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09cee8c5..517699dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-12 Jeffrey Stedfast + + * glib/gchecksum.c (g_checksum_reset): New function to reset the + state of a GChecksum. + (g_checksum_new): Call g_checksum_reset() instead of duplicating + code. + 2008-05-17 Matthias Clasen Bug 528667 – Typos in testing module documentation @@ -45,6 +52,7 @@ * glib/gi18n.c: #include to fix the build. +>>>>>>> .r6902 2008-05-12 Yair Hershkovitz * glib/gi18n.c (g_i18n_init): Coding convention fix. Space between diff --git a/glib/gchecksum.c b/glib/gchecksum.c index 0b0ce54f..bc181693 100644 --- a/glib/gchecksum.c +++ b/glib/gchecksum.c @@ -1114,7 +1114,24 @@ g_checksum_new (GChecksumType checksum_type) checksum = g_slice_new0 (GChecksum); checksum->type = checksum_type; - switch (checksum_type) + g_checksum_reset (checksum); + + return checksum; +} + +/** + * g_checksum_reset: + * @checksum: the #GChecksum to reset + * + * Resets the state of the @checksum back to it's initial state. + **/ +void +g_checksum_reset (GChecksum *checksum) +{ + g_free (checksum->digest_str); + checksum->digest_str = NULL; + + switch (checksum->type) { case G_CHECKSUM_MD5: md5_sum_init (&(checksum->sum.md5)); @@ -1129,8 +1146,6 @@ g_checksum_new (GChecksumType checksum_type) g_assert_not_reached (); break; } - - return checksum; } /** diff --git a/glib/gchecksum.h b/glib/gchecksum.h index 7df3db4d..f0d58a5e 100644 --- a/glib/gchecksum.h +++ b/glib/gchecksum.h @@ -54,6 +54,7 @@ typedef struct _GChecksum GChecksum; gssize g_checksum_type_get_length (GChecksumType checksum_type); GChecksum * g_checksum_new (GChecksumType checksum_type); +void g_checksum_reset (GChecksum *checksum); GChecksum * g_checksum_copy (const GChecksum *checksum); void g_checksum_free (GChecksum *checksum); void g_checksum_update (GChecksum *checksum, -- 2.34.1