Polishing source code - pointer type signature convention.

This commit is contained in:
Martin Dvorak 2018-08-13 08:00:50 +02:00
parent de2c612bb8
commit 98b17abd77
12 changed files with 108 additions and 83 deletions

View file

@ -258,12 +258,12 @@ static const char* HELP_STRING=
// major.minor.revision // major.minor.revision
static const char* VERSION_STRING= static const char* VERSION_STRING=
"hh version \"1.27.0\" (2018-08-1T13:00:00)" "hh version \"1.27.0\" (2018-08-13T12:00:00)"
"\n"; "\n";
// TODO help screen - curses window (tig) // TODO help screen - curses window (tig)
static const char* LABEL_HELP= static const char* LABEL_HELP=
"Type to filter, UP/DOWN move, DEL remove, TAB select, C-f add favorite, C-g cancel"; "Type to filter, UP/DOWN move, RET/DEL remove, TAB select, C-f add favorite, C-g cancel";
#define GETOPT_NO_ARGUMENT 0 #define GETOPT_NO_ARGUMENT 0
#define GETOPT_REQUIRED_ARGUMENT 1 #define GETOPT_REQUIRED_ARGUMENT 1
@ -362,6 +362,7 @@ unsigned recalculate_max_history_items(void)
return hstr->promptItems; return hstr->promptItems;
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void hstr_get_env_configuration(Hstr* hstr) void hstr_get_env_configuration(Hstr* hstr)
{ {
char *hstr_config=getenv(HH_ENV_VAR_CONFIG); char *hstr_config=getenv(HH_ENV_VAR_CONFIG);
@ -469,6 +470,7 @@ unsigned print_prompt(void)
return promptLength; return promptLength;
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void add_to_selection(Hstr* hstr, char* line, unsigned int* index) void add_to_selection(Hstr* hstr, char* line, unsigned int* index)
{ {
if (hstr->unique) { if (hstr->unique) {
@ -514,6 +516,7 @@ void print_confirm_delete(const char* cmd, Hstr* hstr)
refresh(); refresh();
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void print_cmd_deleted_label(const char* cmd, int occurences, Hstr* hstr) void print_cmd_deleted_label(const char* cmd, int occurences, Hstr* hstr)
{ {
char screenLine[CMDLINE_LNG]; char screenLine[CMDLINE_LNG];
@ -549,6 +552,7 @@ void print_regexp_error(const char *errorMessage)
refresh(); refresh();
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void print_cmd_added_favorite_label(const char* cmd, Hstr* hstr) void print_cmd_added_favorite_label(const char* cmd, Hstr* hstr)
{ {
char screenLine[CMDLINE_LNG]; char screenLine[CMDLINE_LNG];
@ -609,6 +613,7 @@ void print_pattern(char* pattern, int y, int x)
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
// TODO don't realloc if size doesn't change // TODO don't realloc if size doesn't change
void hstr_realloc_selection(unsigned size, Hstr* hstr) void hstr_realloc_selection(unsigned size, Hstr* hstr)
{ {
@ -632,6 +637,7 @@ void hstr_realloc_selection(unsigned size, Hstr* hstr)
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
unsigned hstr_make_selection(char* prefix, HistoryItems* history, unsigned maxSelectionCount, Hstr* hstr) unsigned hstr_make_selection(char* prefix, HistoryItems* history, unsigned maxSelectionCount, Hstr* hstr)
{ {
hstr_realloc_selection(maxSelectionCount, hstr); hstr_realloc_selection(maxSelectionCount, hstr);
@ -836,6 +842,7 @@ void print_selection_row(char* text, int y, int width, char* pattern)
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void hstr_print_highlighted_selection_row(char *text, int y, int width, Hstr *hstr) void hstr_print_highlighted_selection_row(char *text, int y, int width, Hstr *hstr)
{ {
UNUSED_ARG(width); UNUSED_ARG(width);
@ -859,6 +866,7 @@ void hstr_print_highlighted_selection_row(char *text, int y, int width, Hstr *hs
color_attr_off(A_BOLD); color_attr_off(A_BOLD);
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
char *hstr_print_selection(unsigned maxHistoryItems, char* pattern, Hstr* hstr) char *hstr_print_selection(unsigned maxHistoryItems, char* pattern, Hstr* hstr)
{ {
char *result=NULL; char *result=NULL;
@ -921,6 +929,7 @@ char *hstr_print_selection(unsigned maxHistoryItems, char* pattern, Hstr* hstr)
return result; return result;
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void highlight_selection(int selectionCursorPosition, int previousSelectionCursorPosition, char* pattern, Hstr* hstr) void highlight_selection(int selectionCursorPosition, int previousSelectionCursorPosition, char* pattern, Hstr* hstr)
{ {
if(previousSelectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { if(previousSelectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) {
@ -983,7 +992,9 @@ void signal_callback_handler_ctrl_c(int signum)
} }
} }
int remove_from_history_model(char* delete, Hstr *hstr) // IMPROVE hstr doesn't have to be passed as parameter - it's global static
// IMPROVE replace delete as it's reserved C++ word (IDEs)
int remove_from_history_model(char* delete, Hstr* hstr)
{ {
if(hstr->historyView==HH_VIEW_FAVORITES) { if(hstr->historyView==HH_VIEW_FAVORITES) {
return favorites_remove(hstr->favorites, delete); return favorites_remove(hstr->favorites, delete);
@ -1001,12 +1012,14 @@ int remove_from_history_model(char* delete, Hstr *hstr)
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void hstr_next_view(Hstr* hstr) void hstr_next_view(Hstr* hstr)
{ {
hstr->historyView++; hstr->historyView++;
hstr->historyView=hstr->historyView%3; hstr->historyView=hstr->historyView%3;
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void stdout_history_and_return(Hstr* hstr) { void stdout_history_and_return(Hstr* hstr) {
unsigned selectionCount=hstr_make_selection(hstr->cmdline, hstr->history, hstr->history->rawCount, hstr); unsigned selectionCount=hstr_make_selection(hstr->cmdline, hstr->history, hstr->history->rawCount, hstr);
if (selectionCount > 0) { if (selectionCount > 0) {
@ -1017,6 +1030,7 @@ void stdout_history_and_return(Hstr* hstr) {
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
char* getResultFromSelection(int selectionCursorPosition, Hstr* hstr, char* result) { char* getResultFromSelection(int selectionCursorPosition, Hstr* hstr, char* result) {
if (hstr->promptBottom) { if (hstr->promptBottom) {
result=hstr->selection[hstr->promptYItemsEnd-selectionCursorPosition]; result=hstr->selection[hstr->promptYItemsEnd-selectionCursorPosition];
@ -1026,6 +1040,7 @@ char* getResultFromSelection(int selectionCursorPosition, Hstr* hstr, char* resu
return result; return result;
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
void loop_to_select(Hstr* hstr) void loop_to_select(Hstr* hstr)
{ {
signal(SIGINT, signal_callback_handler_ctrl_c); signal(SIGINT, signal_callback_handler_ctrl_c);
@ -1413,6 +1428,7 @@ void loop_to_select(Hstr* hstr)
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
// TODO protection from line overflow (snprinf) // TODO protection from line overflow (snprinf)
void hstr_assemble_cmdline_pattern(int argc, char* argv[], Hstr* hstr, int startIndex) void hstr_assemble_cmdline_pattern(int argc, char* argv[], Hstr* hstr, int startIndex)
{ {
@ -1434,6 +1450,7 @@ void hstr_assemble_cmdline_pattern(int argc, char* argv[], Hstr* hstr, int start
} }
} }
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
// TODO make favorites loading lazy (load on the first opening of favorites view) // TODO make favorites loading lazy (load on the first opening of favorites view)
void hstr_init_favorites(Hstr* hstr) void hstr_init_favorites(Hstr* hstr)
{ {
@ -1442,7 +1459,8 @@ void hstr_init_favorites(Hstr* hstr)
favorites_get(hstr->favorites); favorites_get(hstr->favorites);
} }
void hstr_main(Hstr* hstr) // IMPROVE hstr doesn't have to be passed as parameter - it's global static
void hstr_interactive(Hstr* hstr)
{ {
hstr->history=get_prioritized_history(hstr->bigKeys, hstr->blacklist.set); hstr->history=get_prioritized_history(hstr->bigKeys, hstr->blacklist.set);
if(hstr->history) { if(hstr->history) {
@ -1510,7 +1528,8 @@ void hstr_getopt(int argc, char **argv, Hstr *hstr)
} }
} }
int hstrMain(int argc, char* argv[]) // IMPROVE rename this method - is NOT c convention + clash w/ existing name
int hstr_main(int argc, char* argv[])
{ {
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
@ -1521,7 +1540,7 @@ int hstrMain(int argc, char* argv[])
hstr_getopt(argc, argv, hstr); hstr_getopt(argc, argv, hstr);
hstr_init_favorites(hstr); hstr_init_favorites(hstr);
blacklist_load(&hstr->blacklist); blacklist_load(&hstr->blacklist);
hstr_main(hstr); hstr_interactive(hstr);
favorites_destroy(hstr->favorites); favorites_destroy(hstr->favorites);
free(hstr); free(hstr);

View file

@ -26,7 +26,7 @@
#define PID_BUFFER_SIZE 128 #define PID_BUFFER_SIZE 128
// strdup() not in ISO C // strdup() not in ISO C
char *hstr_strdup(const char * s) char* hstr_strdup(const char* s)
{ {
size_t len = 1+strlen(s); size_t len = 1+strlen(s);
char *p = malloc(len); char *p = malloc(len);

View file

@ -27,28 +27,28 @@
#define HASH_MAP_SIZE 10007 #define HASH_MAP_SIZE 10007
struct HashSetNode { struct HashSetNode {
char *key; char* key;
void *value; void* value;
struct HashSetNode *next; struct HashSetNode* next;
}; };
typedef struct { typedef struct {
struct HashSetNode *lists[HASH_MAP_SIZE]; struct HashSetNode* lists[HASH_MAP_SIZE];
int currentSize; int currentSize;
} HashSet; } HashSet;
void hashset_init(HashSet *hs); void hashset_init(HashSet* hs);
int hashset_contains(const HashSet *hs, const char *key); int hashset_contains(const HashSet* hs, const char* key);
int hashset_add(HashSet *hs, const char *key); int hashset_add(HashSet* hs, const char* key);
int hashset_size(const HashSet *hs); int hashset_size(const HashSet* hs);
char** hashset_keys(const HashSet *hs); char** hashset_keys(const HashSet* hs);
void *hashset_get(const HashSet *hm, const char *key); void *hashset_get(const HashSet* hm, const char* key);
int hashset_put(HashSet *hm, const char *key, void *value); int hashset_put(HashSet* hm, const char* key, void* value);
int hashset_remove(const HashSet *hm, const char *key); int hashset_remove(const HashSet* hm, const char* key);
void hashset_stat(const HashSet *hm); void hashset_stat(const HashSet* hm);
void hashset_destroy(HashSet *hs, const bool freeValues); void hashset_destroy(HashSet* hs, const bool freeValues);
#endif #endif

View file

@ -19,6 +19,6 @@
#ifndef HSTR_H_ #ifndef HSTR_H_
#define HSTR_H_ #define HSTR_H_
int hstrMain(int argc, char *argv[]); int hstr_main(int argc, char* argv[]);
#endif #endif

View file

@ -32,13 +32,13 @@ typedef struct {
bool useFile; bool useFile;
bool isLoaded; bool isLoaded;
bool isDefault; bool isDefault;
HashSet *set; HashSet* set;
} Blacklist; } Blacklist;
void blacklist_init(Blacklist *blacklist); void blacklist_init(Blacklist* blacklist);
void blacklist_load(Blacklist *blacklist); void blacklist_load(Blacklist* blacklist);
bool blacklist_in(Blacklist *blacklist, char *cmd); bool blacklist_in(Blacklist* blacklist, char *cmd);
void blacklist_dump(Blacklist *blacklist); void blacklist_dump(Blacklist* blacklist);
void blacklist_destroy(Blacklist *blacklist); void blacklist_destroy(Blacklist* blacklist);
#endif #endif

View file

@ -29,17 +29,17 @@
#define FILE_HH_FAVORITES ".hh_favorites" #define FILE_HH_FAVORITES ".hh_favorites"
typedef struct { typedef struct {
char **items; char** items;
unsigned count; unsigned count;
bool loaded; bool loaded;
HashSet *set; HashSet* set;
} FavoriteItems; } FavoriteItems;
void favorites_init(FavoriteItems *favorites); void favorites_init(FavoriteItems* favorites);
void favorites_get(FavoriteItems *favorites); void favorites_get(FavoriteItems* favorites);
void favorites_add(FavoriteItems *favorites, char *favorite); void favorites_add(FavoriteItems* favorites, char* favorite);
void favorites_choose(FavoriteItems *favorites, char *choice); void favorites_choose(FavoriteItems* favorites, char* choice);
bool favorites_remove(FavoriteItems *favorites, char *almostDead); bool favorites_remove(FavoriteItems* favorites, char* almostDead);
void favorites_destroy(FavoriteItems *favorites); void favorites_destroy(FavoriteItems* favorites);
#endif #endif

View file

@ -41,27 +41,27 @@
typedef struct { typedef struct {
// ranked history // ranked history
char **items; char** items;
unsigned count; unsigned count;
// raw history // raw history
char **rawItems; char** rawItems;
unsigned rawCount; unsigned rawCount;
} HistoryItems; } HistoryItems;
HistoryItems *get_prioritized_history(int optionBigKeys, HashSet *blacklist); HistoryItems* get_prioritized_history(int optionBigKeys, HashSet* blacklist);
HistoryItems *get_history_items(void); HistoryItems* get_history_items(void);
void free_history_items(void); void free_history_items(void);
HistoryItems *prioritize_history(HistoryItems *historyFileItems); HistoryItems* prioritize_history(HistoryItems* historyFileItems);
void free_prioritized_history(void); void free_prioritized_history(void);
void history_mgmt_open(void); void history_mgmt_open(void);
void history_clear_dirty(void); void history_clear_dirty(void);
int history_mgmt_remove_from_system_history(char *cmd); int history_mgmt_remove_from_system_history(char* cmd);
bool history_mgmt_remove_last_history_entry(bool verbose); bool history_mgmt_remove_last_history_entry(bool verbose);
int history_mgmt_remove_from_raw(char *cmd, HistoryItems *history); int history_mgmt_remove_from_raw(char* cmd, HistoryItems* history);
int history_mgmt_remove_from_ranked(char *cmd, HistoryItems *history); int history_mgmt_remove_from_ranked(char* cmd, HistoryItems* history);
void history_mgmt_flush(void); void history_mgmt_flush(void);
#endif #endif

View file

@ -30,11 +30,17 @@ typedef struct {
HashSet cache; HashSet cache;
} HstrRegexp; } HstrRegexp;
void hstr_regexp_init(HstrRegexp *hstrRegexp); void hstr_regexp_init(HstrRegexp* hstrRegexp);
bool hstr_regexp_match(HstrRegexp *hstrRegexp, const char *regexp, const char *text, regmatch_t *match, char *errorMessage, const size_t errorMessageSize); bool hstr_regexp_match(
void hstr_regexp_destroy(HstrRegexp *hstrRegexp); HstrRegexp* hstrRegexp,
const char* regexp,
const char* text,
regmatch_t* match,
char* errorMessage,
const size_t errorMessageSize);
void hstr_regexp_destroy(HstrRegexp* hstrRegexp);
int regexp_compile(regex_t *regexp, const char *regexpText); int regexp_compile(regex_t* regexp, const char* regexpText);
int regexp_match(regex_t *regexp, const char *text); int regexp_match(regex_t* regexp, const char* text);
#endif #endif

View file

@ -32,16 +32,16 @@
#define MIN(a,b) (((a)<(b))?(a):(b)) #define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b))
char *hstr_strdup(const char *s); char *hstr_strdup(const char* s);
int hstr_strlen(const char *s); int hstr_strlen(const char* s);
void hstr_chop(char *s); void hstr_chop(char* s);
#ifndef __CYGWIN__ #ifndef __CYGWIN__
void tiocsti(); void tiocsti();
#endif #endif
void fill_terminal_input(char* cmd, bool padding); void fill_terminal_input(char* cmd, bool padding);
void reverse_char_pointer_array(char **array, unsigned length); void reverse_char_pointer_array(char** array, unsigned length);
void get_hostname(int bufferSize, char *buffer); void get_hostname(int bufferSize, char* buffer);
void toggle_case(char *str, bool lowercase); void toggle_case(char* str, bool lowercase);
bool isZshParentShell(void); bool isZshParentShell(void);
#endif #endif

View file

@ -39,8 +39,8 @@
typedef struct radixitem { typedef struct radixitem {
unsigned key; unsigned key;
void *data; void* data;
struct radixitem *next; struct radixitem* next;
} RadixItem; } RadixItem;
typedef struct radixslot { typedef struct radixslot {
@ -53,22 +53,22 @@ typedef struct {
unsigned size; unsigned size;
unsigned maxKey; unsigned maxKey;
unsigned keyLimit; unsigned keyLimit;
RadixItem ***topDigits; RadixItem*** topDigits;
int optionBigKeys; int optionBigKeys;
RadixSlot **_slotDescriptors; RadixSlot** _slotDescriptors;
unsigned _slotsCount; unsigned _slotsCount;
unsigned _topIndexLimit; unsigned _topIndexLimit;
unsigned _debug; unsigned _debug;
} RadixSorter; } RadixSorter;
void radixsort_init(RadixSorter *rs, unsigned keyLimit); void radixsort_init(RadixSorter* rs, unsigned keyLimit);
void radixsort_set_debug_level(RadixSorter *rs, unsigned debugLevel); void radixsort_set_debug_level(RadixSorter* rs, unsigned debugLevel);
void radixsort_add(RadixSorter *rs, RadixItem *item); void radixsort_add(RadixSorter* rs, RadixItem* item);
RadixItem *radix_cut(RadixSorter *rs, unsigned key, void *data); RadixItem* radix_cut(RadixSorter* rs, unsigned key, void* data);
RadixItem **radixsort_dump(RadixSorter *rs); RadixItem** radixsort_dump(RadixSorter* rs);
void radixsort_destroy(RadixSorter *rs); void radixsort_destroy(RadixSorter* rs);
void radixsort_stat(RadixSorter *rs, bool listing); void radixsort_stat(RadixSorter* rs, bool listing);
#endif /* RADIXSORT_H_ */ #endif /* RADIXSORT_H_ */

View file

@ -18,7 +18,7 @@
#include "include/hstr.h" #include "include/hstr.h"
int main(int argc, char *argv[]) int main(int argc, char* argv[])
{ {
return hstrMain(argc, argv); return hstr_main(argc, argv);
} }

View file

@ -21,31 +21,31 @@
#define GET_TOP_INDEX(KEY) KEY/RADIX_SLOT_SIZE #define GET_TOP_INDEX(KEY) KEY/RADIX_SLOT_SIZE
#define GET_LOW_INDEX(KEY) KEY%RADIX_SLOT_SIZE #define GET_LOW_INDEX(KEY) KEY%RADIX_SLOT_SIZE
void radixsort_init(RadixSorter *rs, unsigned keyLimit) void radixsort_init(RadixSorter* rs, unsigned keyLimit)
{ {
rs->optionBigKeys=RADIX_BIG_KEYS_SKIP; rs->optionBigKeys=RADIX_BIG_KEYS_SKIP;
rs->_topIndexLimit=GET_TOP_INDEX(keyLimit); rs->_topIndexLimit=GET_TOP_INDEX(keyLimit);
rs->size=0; rs->size=0;
rs->topDigits=malloc(rs->_topIndexLimit * sizeof(RadixItem ***)); rs->topDigits=malloc(rs->_topIndexLimit * sizeof(RadixItem***));
memset(rs->topDigits, 0, rs->_topIndexLimit * sizeof(RadixItem ***)); memset(rs->topDigits, 0, rs->_topIndexLimit * sizeof(RadixItem***));
rs->maxKey=0; rs->maxKey=0;
rs->keyLimit=keyLimit; rs->keyLimit=keyLimit;
rs->_slotDescriptors=malloc(rs->_topIndexLimit * sizeof(RadixSlot **)); rs->_slotDescriptors=malloc(rs->_topIndexLimit * sizeof(RadixSlot**));
rs->_slotsCount=0; rs->_slotsCount=0;
rs->_debug=RADIX_DEBUG_LEVEL_NONE; rs->_debug=RADIX_DEBUG_LEVEL_NONE;
} }
void radixsort_set_debug_level(RadixSorter *rs, unsigned debugLevel) void radixsort_set_debug_level(RadixSorter* rs, unsigned debugLevel)
{ {
rs->_debug=debugLevel; rs->_debug=debugLevel;
} }
RadixItem **radixsort_get_slot(RadixSorter *rs, unsigned topIndex) RadixItem** radixsort_get_slot(RadixSorter* rs, unsigned topIndex)
{ {
RadixItem **slot=malloc(RADIX_SLOT_SIZE * sizeof(RadixItem *)); RadixItem **slot=malloc(RADIX_SLOT_SIZE * sizeof(RadixItem*));
memset(slot, 0, RADIX_SLOT_SIZE * sizeof(RadixItem *)); memset(slot, 0, RADIX_SLOT_SIZE * sizeof(RadixItem*));
RadixSlot *descriptor=malloc(sizeof(RadixSlot)); RadixSlot *descriptor=malloc(sizeof(RadixSlot));
descriptor->min=rs->keyLimit; descriptor->min=rs->keyLimit;
@ -57,7 +57,7 @@ RadixItem **radixsort_get_slot(RadixSorter *rs, unsigned topIndex)
return slot; return slot;
} }
void radixsort_add(RadixSorter *rs, RadixItem *item) void radixsort_add(RadixSorter* rs, RadixItem* item)
{ {
if(item->key > rs->keyLimit) { if(item->key > rs->keyLimit) {
if(rs->_debug > RADIX_DEBUG_LEVEL_NONE) { if(rs->_debug > RADIX_DEBUG_LEVEL_NONE) {
@ -81,7 +81,7 @@ void radixsort_add(RadixSorter *rs, RadixItem *item)
rs->topDigits[topIndex]=radixsort_get_slot(rs, topIndex); rs->topDigits[topIndex]=radixsort_get_slot(rs, topIndex);
} }
RadixItem *chain=rs->topDigits[topIndex][lowIndex]; RadixItem* chain=rs->topDigits[topIndex][lowIndex];
rs->topDigits[topIndex][lowIndex]=item; rs->topDigits[topIndex][lowIndex]=item;
if(chain==NULL) { if(chain==NULL) {
item->next=NULL; item->next=NULL;
@ -96,7 +96,7 @@ void radixsort_add(RadixSorter *rs, RadixItem *item)
rs->_slotDescriptors[topIndex]->size++; rs->_slotDescriptors[topIndex]->size++;
} }
void radix_dec_slot_descriptor_size(RadixSorter *rs, RadixSlot *descriptor, unsigned key, unsigned topIndex) void radix_dec_slot_descriptor_size(RadixSorter* rs, RadixSlot *descriptor, unsigned key, unsigned topIndex)
{ {
UNUSED_ARG(key); UNUSED_ARG(key);
@ -117,7 +117,7 @@ void radix_dec_slot_descriptor_size(RadixSorter *rs, RadixSlot *descriptor, unsi
} }
} }
RadixItem *radix_cut(RadixSorter *rs, unsigned key, void *data) RadixItem* radix_cut(RadixSorter* rs, unsigned key, void* data)
{ {
// TODO optimization: fix min/max on cut of a value // TODO optimization: fix min/max on cut of a value
if(key <= rs->maxKey) { if(key <= rs->maxKey) {
@ -151,7 +151,7 @@ RadixItem *radix_cut(RadixSorter *rs, unsigned key, void *data)
return NULL; return NULL;
} }
RadixItem **radixsort_dump(RadixSorter *rs) RadixItem** radixsort_dump(RadixSorter* rs)
{ {
if(rs->size>0) { if(rs->size>0) {
RadixItem **result=malloc(rs->size * sizeof(RadixItem *)); RadixItem **result=malloc(rs->size * sizeof(RadixItem *));
@ -185,7 +185,7 @@ RadixItem **radixsort_dump(RadixSorter *rs)
return NULL; return NULL;
} }
void radixsort_stat(RadixSorter *rs, bool listing) void radixsort_stat(RadixSorter* rs, bool listing)
{ {
printf("\n Radixsort (size/max/limit/slot count): %u %u %u %u", rs->size, rs->maxKey, rs->keyLimit, rs->_slotsCount); printf("\n Radixsort (size/max/limit/slot count): %u %u %u %u", rs->size, rs->maxKey, rs->keyLimit, rs->_slotsCount);
unsigned memory=rs->_topIndexLimit * sizeof(RadixItem ***); unsigned memory=rs->_topIndexLimit * sizeof(RadixItem ***);
@ -226,7 +226,7 @@ void radixsort_stat(RadixSorter *rs, bool listing)
fflush(stdout); fflush(stdout);
} }
void radixsort_destroy(RadixSorter *rs) void radixsort_destroy(RadixSorter* rs)
{ {
// radix items: DONE (passed on dump() by reference) // radix items: DONE (passed on dump() by reference)
// rs: DONE (created and destroyed by caller) // rs: DONE (created and destroyed by caller)