From 145ea7700634e95b81f8cb148928634dc0d0bdbb Mon Sep 17 00:00:00 2001 From: Liu Chao Date: Thu, 4 Jul 2013 13:44:07 +0800 Subject: [PATCH] =?UTF-8?q?BKDRHash=E5=87=BD=E6=95=B0=E8=BD=AC=E7=A7=BB?= =?UTF-8?q?=E8=87=B3misc.c=EF=BF=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/LCUI/LCUI_Misc.h | 3 +++ src/LCUI_Memory.c | 25 +++++-------------------- src/misc/misc.c | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/LCUI/LCUI_Misc.h b/include/LCUI/LCUI_Misc.h index 23bb2da8..837b74d4 100755 --- a/include/LCUI/LCUI_Misc.h +++ b/include/LCUI/LCUI_Misc.h @@ -136,6 +136,9 @@ GetIntOrFloat( char *str, IntOrFloat_t *combo_num ); LCUI_API int get_PX_PT_t( char *str, PX_PT_t *combo_num ); +/** 根据给定的字符串,生成一个ID */ +unsigned int BKDRHash( const char *str ); + /* 录制屏幕指定区域的内容 */ LCUI_API int LCUIScreen_StartRecord( LCUI_Rect area ); diff --git a/src/LCUI_Memory.c b/src/LCUI_Memory.c index 91bbb73f..b90c7bcd 100644 --- a/src/LCUI_Memory.c +++ b/src/LCUI_Memory.c @@ -27,17 +27,17 @@ * @brief 内存管理. * @author 刘超 * @warning - * 版权所有 (C) 2012-2013 归属于 \n + * 版权所有 (C) 2012-2013 归属于 \n * 刘超 \n * \n * 这个文件是LCUI项目的一部分,并且只可以根据GPLv2许可协议来使用、更改和发布。 \n * \n - * (GPLv2 是 GNU通用公共许可证第二版 的英文缩写) \n + * (GPLv2 是 GNU通用公共许可证第二版 的英文缩写) \n * \n - * 继续使用、修改或发布本文件,表明您已经阅读并完全理解和接受这个许可协议。 \n + * 继续使用、修改或发布本文件,表明您已经阅读并完全理解和接受这个许可协议。 \n * \n - * LCUI 项目是基于使用目的而加以散布的,但不负任何担保责任,甚至没有适销性或特定用途 \n - * 的隐含担保,详情请参照GPLv2许可协议。 \n + * LCUI 项目是基于使用目的而加以散布的,但不负任何担保责任,甚至没有适销性或特定\n + * 用途的隐含担保,详情请参照GPLv2许可协议。 \n * \n * 您应已收到附随于本文件的GPLv2许可协议的副本,它通常在LICENSE.TXT文件中,如果 \n * 没有,请查看:. \n @@ -91,21 +91,6 @@ typedef struct rb_tree_t_ { rb_tree_t global_mem_data; rb_tree_t global_mem_class_info; -static unsigned int BKDRHash(char *str) -{ - unsigned int seed = 131; - unsigned int hash = 0; - - if( str == NULL ) { - return 0; - } - while (*str) { - hash = hash * seed + (*str++); - } - - return (hash & 0x7FFFFFFF); -} - static void rb_tree_init( rb_tree_t *rbt ) { rbt->root = NULL; diff --git a/src/misc/misc.c b/src/misc/misc.c index 070c5761..c24e1016 100755 --- a/src/misc/misc.c +++ b/src/misc/misc.c @@ -338,3 +338,18 @@ get_PX_PT_t( char *str, PX_PT_t *combo_num ) return 0; } +/** 根据给定的字符串,生成一个ID */ +unsigned int BKDRHash( const char *str ) +{ + unsigned int seed = 131; + unsigned int hash = 0; + + if( str == NULL ) { + return 0; + } + while (*str) { + hash = hash * seed + (*str++); + } + + return (hash & 0x7FFFFFFF); +}