diff --git a/src/locked_list.h b/src/locked_list.h index abe0ddb..11fda79 100644 --- a/src/locked_list.h +++ b/src/locked_list.h @@ -24,6 +24,11 @@ extern "C" { return 0; } + static inline void locked_list_destroy(FCLockedList *list) + { + pthread_mutex_destroy(&list->lock); + } + static inline void locked_list_add(struct fc_list_head *_new, FCLockedList *list) { diff --git a/src/md5.c b/src/md5.c index 4ca8b77..46db4ef 100644 --- a/src/md5.c +++ b/src/md5.c @@ -311,7 +311,7 @@ MD5_memset(POINTER output, int value, unsigned int len) /* * Digests a string */ -int my_md5_string(char *string,unsigned char digest[16]) +int my_md5_string(char *string, unsigned char digest[16]) { MD5_CTX context; unsigned int len = strlen(string); @@ -332,25 +332,22 @@ int my_md5_buffer(char *buffer, unsigned int len, unsigned char digest[16]) return 0; } -int my_md5_file(char *filename,unsigned char digest[16]) +int my_md5_file(char *filename, unsigned char digest[16]) { FILE *file; MD5_CTX context; int len; - unsigned char buffer[1024]; + unsigned char buff[16 * 1024]; - if ((file = fopen(filename, "rb")) == NULL) + if ((file = fopen(filename, "rb")) == NULL) { return -1; - else { - my_md5_init(&context); - while ((len = fread(buffer, 1, 1024, file)) > 0) - { - my_md5_update(&context, buffer, len); - } - my_md5_final(digest, &context); + } - fclose(file); - } - return 0; + my_md5_init(&context); + while ((len = fread(buff, 1, sizeof(buff), file)) > 0) { + my_md5_update(&context, buff, len); + } + my_md5_final(digest, &context); + fclose(file); + return 0; } - diff --git a/src/md5.h b/src/md5.h index 0fa2375..1ef3a6a 100644 --- a/src/md5.h +++ b/src/md5.h @@ -41,12 +41,12 @@ int my_md5_file(char *filename, unsigned char digest[16]); */ int my_md5_buffer(char *buffer, unsigned int len, unsigned char digest[16]); -void my_md5_init (MD5_CTX *context); +void my_md5_init(MD5_CTX *context); -void my_md5_update (MD5_CTX *context, unsigned char *input, +void my_md5_update(MD5_CTX *context, unsigned char *input, unsigned int inputLen); -void my_md5_final (unsigned char digest[16], MD5_CTX *context); +void my_md5_final(unsigned char digest[16], MD5_CTX *context); #ifdef __cplusplus }