1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[loc] hash functions improvements

* Fix a leak when freeing the hash table (actual size is htab_size+1)
* Use a better hash algorithm
* Use a larger table with a size already set to a prime
This commit is contained in:
Mehmetali KURAN 2013-11-02 18:45:06 +00:00
parent 434bae8954
commit c6da7311b0
3 changed files with 14 additions and 13 deletions

View file

@ -140,7 +140,7 @@ static void htab_destroy(void)
return;
}
for (i=0; i<htab_size; i++) {
for (i=0; i<htab_size+1; i++) {
if (htab_table[i].used) {
safe_free(htab_table[i].str);
}
@ -162,18 +162,18 @@ static uint32_t htab_hash(char* str)
{
uint32_t hval, hval2;
uint32_t idx;
uint32_t r = 5381;
uint32_t r = 0;
int c;
char* sz = str;
if (str == NULL)
return 0;
// Compute main hash value (algorithm suggested by Nokia)
// TODO: THIS ALGORITHM SUUUUUUUUUUUUUUCKS!!!!
// Uncomment 'uprintf("hash collision' below to find out why...
// Compute main hash value using sdbm's algorithm (empirically
// shown to produce half the collisions as djb2's).
// See http://www.cse.yorku.ca/~oz/hash.html
while ((c = *sz++) != 0)
r = ((r << 5) + r) + c;
r = c + (r << 6) + (r << 16) - r;
if (r == 0)
++r;

View file

@ -22,10 +22,11 @@
#pragma once
// Number of concurrent localization messages. Must be a power of 2.
// Number of concurrent localization messages (i.e. messages we can concurrently
// reference at the same time). Must be a power of 2.
#define LOC_MESSAGE_NB 8
#define LOC_MESSAGE_SIZE 2048
#define LOC_HTAB_SIZE 512
#define LOC_HTAB_SIZE 1031 // Using a prime speeds up the hash table init
// The [v]ersion major from a translation must match this number or
// the translation will be ignored

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.4.0.306"
CAPTION "Rufus v1.4.0.307"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -289,8 +289,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,0,306
PRODUCTVERSION 1,4,0,306
FILEVERSION 1,4,0,307
PRODUCTVERSION 1,4,0,307
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -307,13 +307,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.0.306"
VALUE "FileVersion", "1.4.0.307"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.0.306"
VALUE "ProductVersion", "1.4.0.307"
END
END
BLOCK "VarFileInfo"