mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-20 12:14:55 +00:00
Don't cast malloc.
There is no need to cast the result of library functions that return void *; it makes your code hard to read, adds no value, and can hide a bug if you don't have a valid prototype in scope. See http://c-faq.com/malloc/mallocnocast.html
This commit is contained in:
parent
c26cdb97f5
commit
eaba94fa13
3 changed files with 6 additions and 6 deletions
|
@ -169,7 +169,7 @@ int damerau_levenshtein_with_size (
|
|||
return parSourceLen * parDeleteCost;
|
||||
|
||||
const int table_length = parSourceLen * parTargetLen;
|
||||
table = (int*)malloc(sizeof(int) * table_length);
|
||||
table = malloc(sizeof(int) * table_length);
|
||||
memset(table, 0, sizeof(int) * table_length);
|
||||
|
||||
sourceIndexByCharacter = pblMapNewHashMap();
|
||||
|
|
|
@ -46,7 +46,7 @@ void find_actions (char*** parOut, size_t* parCount) {
|
|||
return;
|
||||
}
|
||||
|
||||
*parOut = (char**)malloc(sizeof(char*) * list.count);
|
||||
*parOut = malloc(sizeof(char*) * list.count);
|
||||
list.list = *parOut;
|
||||
list.used = 0;
|
||||
foreach_dir(&push_action, &list);
|
||||
|
@ -79,7 +79,7 @@ static void foreach_dir (void(*parAction)(const char*, ActionList*), ActionList*
|
|||
d = opendir(ACTIONS_SEARCH_PATH);
|
||||
if (d) {
|
||||
path_buff_length = lengthof(ACTIONS_SEARCH_PATH) + 512;
|
||||
path_buff = (char*)malloc(path_buff_length);
|
||||
path_buff = malloc(path_buff_length);
|
||||
strncpy(path_buff, ACTIONS_SEARCH_PATH, lengthof(ACTIONS_SEARCH_PATH));
|
||||
search_path_length = lengthof(ACTIONS_SEARCH_PATH) - 1;
|
||||
if ('/' != path_buff[search_path_length - 1]) {
|
||||
|
@ -133,7 +133,7 @@ static void push_action (const char* parName, ActionList* parList) {
|
|||
}
|
||||
|
||||
name_len = strlen(parName);
|
||||
parList->list[parList->used] = (char*)malloc(1 + name_len);
|
||||
parList->list[parList->used] = malloc(1 + name_len);
|
||||
strcpy(parList->list[parList->used], parName);
|
||||
++parList->used;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
action_path_length += strlen(actions[selected_action]);
|
||||
++action_path_length;
|
||||
|
||||
action_path = (char*)malloc(action_path_length);
|
||||
action_path = malloc(action_path_length);
|
||||
memcpy(action_path, ACTIONS_SEARCH_PATH, lengthof(ACTIONS_SEARCH_PATH) - 1);
|
||||
z = lengthof(ACTIONS_SEARCH_PATH) - 1;
|
||||
if (ACTIONS_SEARCH_PATH[lengthof(ACTIONS_SEARCH_PATH) - 2] != '/') {
|
||||
|
@ -123,7 +123,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
|
||||
free_actions(actions, actions_count);
|
||||
|
||||
argv = (char**)malloc(sizeof(char*) * (parArgc - 1 + 1));
|
||||
argv = malloc(sizeof(char*) * (parArgc - 1 + 1));
|
||||
argv[0] = action_path;
|
||||
for (z = 2; z < parArgc; ++z) {
|
||||
argv[z - 1] = parArgv[z];
|
||||
|
|
Loading…
Add table
Reference in a new issue