mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-06 01:21:24 -04:00
[vhd] improve handing of user selected filename on save to VHD/FFU
* Use of '*.*' as pattern in file save dialog could lead to assert and crash, so we now try to derive the type of image to be saved from the file extension. We also did not properly handle user cancellation in the file save dialog. * Also update iso9660/iso9660_fs.c to latest proposal of El Torito image handling. * Also add a couple asserts in the hash table functions so that, if these ever get triggered we will pick them from Windows Store reports, and clean up code.
This commit is contained in:
parent
018ed3414b
commit
c2b2624b62
4 changed files with 61 additions and 26 deletions
16
src/stdfn.c
16
src/stdfn.c
|
@ -80,8 +80,9 @@ BOOL htab_create(uint32_t nel, htab_table* htab)
|
|||
if (htab == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
assert(htab->table == NULL);
|
||||
if (htab->table != NULL) {
|
||||
uprintf("warning: htab_create() was called with a non empty table");
|
||||
uprintf("Warning: htab_create() was called with a non empty table");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ BOOL htab_create(uint32_t nel, htab_table* htab)
|
|||
// allocate memory and zero out.
|
||||
htab->table = (htab_entry*)calloc(htab->size + 1, sizeof(htab_entry));
|
||||
if (htab->table == NULL) {
|
||||
uprintf("could not allocate space for hash table\n");
|
||||
uprintf("Could not allocate space for hash table");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -166,7 +167,7 @@ uint32_t htab_hash(char* str, htab_table* htab)
|
|||
// existing hash
|
||||
return idx;
|
||||
}
|
||||
// uprintf("hash collision ('%s' vs '%s')\n", str, htab->table[idx].str);
|
||||
// uprintf("Hash collision ('%s' vs '%s')", str, htab->table[idx].str);
|
||||
|
||||
// Second hash function, as suggested in [Knuth]
|
||||
hval2 = 1 + hval % (htab->size - 2);
|
||||
|
@ -196,19 +197,20 @@ uint32_t htab_hash(char* str, htab_table* htab)
|
|||
// Not found => New entry
|
||||
|
||||
// If the table is full return an error
|
||||
assert(htab->filled < htab->size);
|
||||
if (htab->filled >= htab->size) {
|
||||
uprintf("hash table is full (%d entries)", htab->size);
|
||||
uprintf("Hash table is full (%d entries)", htab->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
safe_free(htab->table[idx].str);
|
||||
htab->table[idx].used = hval;
|
||||
htab->table[idx].str = (char*) malloc(safe_strlen(str)+1);
|
||||
htab->table[idx].str = (char*) malloc(safe_strlen(str) + 1);
|
||||
if (htab->table[idx].str == NULL) {
|
||||
uprintf("could not duplicate string for hash table\n");
|
||||
uprintf("Could not duplicate string for hash table");
|
||||
return 0;
|
||||
}
|
||||
memcpy(htab->table[idx].str, str, safe_strlen(str)+1);
|
||||
memcpy(htab->table[idx].str, str, safe_strlen(str) + 1);
|
||||
++htab->filled;
|
||||
|
||||
return idx;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue