New function to reset the state of a GChecksum. (g_checksum_new): Call

2008-05-12  Jeffrey Stedfast  <fejj@novell.com>

	* 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
This commit is contained in:
Jeffrey Stedfast 2008-05-17 16:53:54 +00:00 committed by Jeffrey Stedfast
parent a30f8df3c8
commit d238669ef0
3 changed files with 27 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2008-05-12 Jeffrey Stedfast <fejj@novell.com>
* 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 <mclasen@redhat.com>
Bug 528667 Typos in testing module documentation
@ -45,6 +52,7 @@
* glib/gi18n.c: #include <locale.h> to fix the build.
>>>>>>> .r6902
2008-05-12 Yair Hershkovitz <yairhr@gmail.com>
* glib/gi18n.c (g_i18n_init): Coding convention fix. Space between

View File

@ -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;
}
/**

View File

@ -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,