diff --git a/ChangeLog b/ChangeLog index 09cee8c5e..517699dc1 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 0b0ce54fc..bc1816930 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 7df3db4df..f0d58a5e7 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,