mirror of
https://github.com/dvorka/hstr.git
synced 2025-09-04 03:24:31 +08:00
Polishing source code - pointer type signature convention.
This commit is contained in:
parent
de2c612bb8
commit
98b17abd77
12 changed files with 108 additions and 83 deletions
31
src/hstr.c
31
src/hstr.c
|
@ -258,12 +258,12 @@ static const char* HELP_STRING=
|
|||
|
||||
// major.minor.revision
|
||||
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";
|
||||
|
||||
// TODO help screen - curses window (tig)
|
||||
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_REQUIRED_ARGUMENT 1
|
||||
|
@ -362,6 +362,7 @@ unsigned recalculate_max_history_items(void)
|
|||
return hstr->promptItems;
|
||||
}
|
||||
|
||||
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
|
||||
void hstr_get_env_configuration(Hstr* hstr)
|
||||
{
|
||||
char *hstr_config=getenv(HH_ENV_VAR_CONFIG);
|
||||
|
@ -469,6 +470,7 @@ unsigned print_prompt(void)
|
|||
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)
|
||||
{
|
||||
if (hstr->unique) {
|
||||
|
@ -514,6 +516,7 @@ void print_confirm_delete(const char* cmd, Hstr* hstr)
|
|||
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)
|
||||
{
|
||||
char screenLine[CMDLINE_LNG];
|
||||
|
@ -549,6 +552,7 @@ void print_regexp_error(const char *errorMessage)
|
|||
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)
|
||||
{
|
||||
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
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// 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 *result=NULL;
|
||||
|
@ -921,6 +929,7 @@ char *hstr_print_selection(unsigned maxHistoryItems, char* pattern, Hstr* hstr)
|
|||
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)
|
||||
{
|
||||
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) {
|
||||
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)
|
||||
{
|
||||
hstr->historyView++;
|
||||
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) {
|
||||
unsigned selectionCount=hstr_make_selection(hstr->cmdline, hstr->history, hstr->history->rawCount, hstr);
|
||||
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) {
|
||||
if (hstr->promptBottom) {
|
||||
result=hstr->selection[hstr->promptYItemsEnd-selectionCursorPosition];
|
||||
|
@ -1026,6 +1040,7 @@ char* getResultFromSelection(int selectionCursorPosition, Hstr* hstr, char* resu
|
|||
return result;
|
||||
}
|
||||
|
||||
// IMPROVE hstr doesn't have to be passed as parameter - it's global static
|
||||
void loop_to_select(Hstr* hstr)
|
||||
{
|
||||
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)
|
||||
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)
|
||||
void hstr_init_favorites(Hstr* hstr)
|
||||
{
|
||||
|
@ -1442,7 +1459,8 @@ void hstr_init_favorites(Hstr* hstr)
|
|||
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);
|
||||
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, "");
|
||||
|
||||
|
@ -1521,7 +1540,7 @@ int hstrMain(int argc, char* argv[])
|
|||
hstr_getopt(argc, argv, hstr);
|
||||
hstr_init_favorites(hstr);
|
||||
blacklist_load(&hstr->blacklist);
|
||||
hstr_main(hstr);
|
||||
hstr_interactive(hstr);
|
||||
|
||||
favorites_destroy(hstr->favorites);
|
||||
free(hstr);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#define PID_BUFFER_SIZE 128
|
||||
|
||||
// strdup() not in ISO C
|
||||
char *hstr_strdup(const char * s)
|
||||
char* hstr_strdup(const char* s)
|
||||
{
|
||||
size_t len = 1+strlen(s);
|
||||
char *p = malloc(len);
|
||||
|
|
|
@ -27,28 +27,28 @@
|
|||
#define HASH_MAP_SIZE 10007
|
||||
|
||||
struct HashSetNode {
|
||||
char *key;
|
||||
void *value;
|
||||
struct HashSetNode *next;
|
||||
char* key;
|
||||
void* value;
|
||||
struct HashSetNode* next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct HashSetNode *lists[HASH_MAP_SIZE];
|
||||
struct HashSetNode* lists[HASH_MAP_SIZE];
|
||||
int currentSize;
|
||||
} HashSet;
|
||||
|
||||
void hashset_init(HashSet *hs);
|
||||
void hashset_init(HashSet* hs);
|
||||
|
||||
int hashset_contains(const HashSet *hs, const char *key);
|
||||
int hashset_add(HashSet *hs, const char *key);
|
||||
int hashset_size(const HashSet *hs);
|
||||
char** hashset_keys(const HashSet *hs);
|
||||
int hashset_contains(const HashSet* hs, const char* key);
|
||||
int hashset_add(HashSet* hs, const char* key);
|
||||
int hashset_size(const HashSet* hs);
|
||||
char** hashset_keys(const HashSet* hs);
|
||||
|
||||
void *hashset_get(const HashSet *hm, const char *key);
|
||||
int hashset_put(HashSet *hm, const char *key, void *value);
|
||||
int hashset_remove(const HashSet *hm, const char *key);
|
||||
void hashset_stat(const HashSet *hm);
|
||||
void *hashset_get(const HashSet* hm, const char* key);
|
||||
int hashset_put(HashSet* hm, const char* key, void* value);
|
||||
int hashset_remove(const HashSet* hm, const char* key);
|
||||
void hashset_stat(const HashSet* hm);
|
||||
|
||||
void hashset_destroy(HashSet *hs, const bool freeValues);
|
||||
void hashset_destroy(HashSet* hs, const bool freeValues);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
#ifndef HSTR_H_
|
||||
#define HSTR_H_
|
||||
|
||||
int hstrMain(int argc, char *argv[]);
|
||||
int hstr_main(int argc, char* argv[]);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,13 +32,13 @@ typedef struct {
|
|||
bool useFile;
|
||||
bool isLoaded;
|
||||
bool isDefault;
|
||||
HashSet *set;
|
||||
HashSet* set;
|
||||
} Blacklist;
|
||||
|
||||
void blacklist_init(Blacklist *blacklist);
|
||||
void blacklist_load(Blacklist *blacklist);
|
||||
bool blacklist_in(Blacklist *blacklist, char *cmd);
|
||||
void blacklist_dump(Blacklist *blacklist);
|
||||
void blacklist_destroy(Blacklist *blacklist);
|
||||
void blacklist_init(Blacklist* blacklist);
|
||||
void blacklist_load(Blacklist* blacklist);
|
||||
bool blacklist_in(Blacklist* blacklist, char *cmd);
|
||||
void blacklist_dump(Blacklist* blacklist);
|
||||
void blacklist_destroy(Blacklist* blacklist);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,17 +29,17 @@
|
|||
#define FILE_HH_FAVORITES ".hh_favorites"
|
||||
|
||||
typedef struct {
|
||||
char **items;
|
||||
char** items;
|
||||
unsigned count;
|
||||
bool loaded;
|
||||
HashSet *set;
|
||||
HashSet* set;
|
||||
} FavoriteItems;
|
||||
|
||||
void favorites_init(FavoriteItems *favorites);
|
||||
void favorites_get(FavoriteItems *favorites);
|
||||
void favorites_add(FavoriteItems *favorites, char *favorite);
|
||||
void favorites_choose(FavoriteItems *favorites, char *choice);
|
||||
bool favorites_remove(FavoriteItems *favorites, char *almostDead);
|
||||
void favorites_destroy(FavoriteItems *favorites);
|
||||
void favorites_init(FavoriteItems* favorites);
|
||||
void favorites_get(FavoriteItems* favorites);
|
||||
void favorites_add(FavoriteItems* favorites, char* favorite);
|
||||
void favorites_choose(FavoriteItems* favorites, char* choice);
|
||||
bool favorites_remove(FavoriteItems* favorites, char* almostDead);
|
||||
void favorites_destroy(FavoriteItems* favorites);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,27 +41,27 @@
|
|||
|
||||
typedef struct {
|
||||
// ranked history
|
||||
char **items;
|
||||
char** items;
|
||||
unsigned count;
|
||||
// raw history
|
||||
char **rawItems;
|
||||
char** rawItems;
|
||||
unsigned rawCount;
|
||||
} 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);
|
||||
|
||||
HistoryItems *prioritize_history(HistoryItems *historyFileItems);
|
||||
HistoryItems* prioritize_history(HistoryItems* historyFileItems);
|
||||
void free_prioritized_history(void);
|
||||
|
||||
void history_mgmt_open(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);
|
||||
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_raw(char* cmd, HistoryItems* history);
|
||||
int history_mgmt_remove_from_ranked(char* cmd, HistoryItems* history);
|
||||
void history_mgmt_flush(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,11 +30,17 @@ typedef struct {
|
|||
HashSet cache;
|
||||
} 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);
|
||||
void hstr_regexp_destroy(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);
|
||||
void hstr_regexp_destroy(HstrRegexp* hstrRegexp);
|
||||
|
||||
int regexp_compile(regex_t *regexp, const char *regexpText);
|
||||
int regexp_match(regex_t *regexp, const char *text);
|
||||
int regexp_compile(regex_t* regexp, const char* regexpText);
|
||||
int regexp_match(regex_t* regexp, const char* text);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,16 +32,16 @@
|
|||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
char *hstr_strdup(const char *s);
|
||||
int hstr_strlen(const char *s);
|
||||
void hstr_chop(char *s);
|
||||
char *hstr_strdup(const char* s);
|
||||
int hstr_strlen(const char* s);
|
||||
void hstr_chop(char* s);
|
||||
#ifndef __CYGWIN__
|
||||
void tiocsti();
|
||||
#endif
|
||||
void fill_terminal_input(char* cmd, bool padding);
|
||||
void reverse_char_pointer_array(char **array, unsigned length);
|
||||
void get_hostname(int bufferSize, char *buffer);
|
||||
void toggle_case(char *str, bool lowercase);
|
||||
void reverse_char_pointer_array(char** array, unsigned length);
|
||||
void get_hostname(int bufferSize, char* buffer);
|
||||
void toggle_case(char* str, bool lowercase);
|
||||
bool isZshParentShell(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
|
||||
typedef struct radixitem {
|
||||
unsigned key;
|
||||
void *data;
|
||||
struct radixitem *next;
|
||||
void* data;
|
||||
struct radixitem* next;
|
||||
} RadixItem;
|
||||
|
||||
typedef struct radixslot {
|
||||
|
@ -53,22 +53,22 @@ typedef struct {
|
|||
unsigned size;
|
||||
unsigned maxKey;
|
||||
unsigned keyLimit;
|
||||
RadixItem ***topDigits;
|
||||
RadixItem*** topDigits;
|
||||
|
||||
int optionBigKeys;
|
||||
|
||||
RadixSlot **_slotDescriptors;
|
||||
RadixSlot** _slotDescriptors;
|
||||
unsigned _slotsCount;
|
||||
unsigned _topIndexLimit;
|
||||
unsigned _debug;
|
||||
} RadixSorter;
|
||||
|
||||
void radixsort_init(RadixSorter *rs, unsigned keyLimit);
|
||||
void radixsort_set_debug_level(RadixSorter *rs, unsigned debugLevel);
|
||||
void radixsort_add(RadixSorter *rs, RadixItem *item);
|
||||
RadixItem *radix_cut(RadixSorter *rs, unsigned key, void *data);
|
||||
RadixItem **radixsort_dump(RadixSorter *rs);
|
||||
void radixsort_destroy(RadixSorter *rs);
|
||||
void radixsort_stat(RadixSorter *rs, bool listing);
|
||||
void radixsort_init(RadixSorter* rs, unsigned keyLimit);
|
||||
void radixsort_set_debug_level(RadixSorter* rs, unsigned debugLevel);
|
||||
void radixsort_add(RadixSorter* rs, RadixItem* item);
|
||||
RadixItem* radix_cut(RadixSorter* rs, unsigned key, void* data);
|
||||
RadixItem** radixsort_dump(RadixSorter* rs);
|
||||
void radixsort_destroy(RadixSorter* rs);
|
||||
void radixsort_stat(RadixSorter* rs, bool listing);
|
||||
|
||||
#endif /* RADIXSORT_H_ */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#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);
|
||||
}
|
||||
|
|
|
@ -21,31 +21,31 @@
|
|||
#define GET_TOP_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->_topIndexLimit=GET_TOP_INDEX(keyLimit);
|
||||
rs->size=0;
|
||||
rs->topDigits=malloc(rs->_topIndexLimit * sizeof(RadixItem ***));
|
||||
memset(rs->topDigits, 0, rs->_topIndexLimit * sizeof(RadixItem ***));
|
||||
rs->topDigits=malloc(rs->_topIndexLimit * sizeof(RadixItem***));
|
||||
memset(rs->topDigits, 0, rs->_topIndexLimit * sizeof(RadixItem***));
|
||||
rs->maxKey=0;
|
||||
rs->keyLimit=keyLimit;
|
||||
|
||||
rs->_slotDescriptors=malloc(rs->_topIndexLimit * sizeof(RadixSlot **));
|
||||
rs->_slotDescriptors=malloc(rs->_topIndexLimit * sizeof(RadixSlot**));
|
||||
rs->_slotsCount=0;
|
||||
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;
|
||||
}
|
||||
|
||||
RadixItem **radixsort_get_slot(RadixSorter *rs, unsigned topIndex)
|
||||
RadixItem** radixsort_get_slot(RadixSorter* rs, unsigned topIndex)
|
||||
{
|
||||
RadixItem **slot=malloc(RADIX_SLOT_SIZE * sizeof(RadixItem *));
|
||||
memset(slot, 0, RADIX_SLOT_SIZE * sizeof(RadixItem *));
|
||||
RadixItem **slot=malloc(RADIX_SLOT_SIZE * sizeof(RadixItem*));
|
||||
memset(slot, 0, RADIX_SLOT_SIZE * sizeof(RadixItem*));
|
||||
|
||||
RadixSlot *descriptor=malloc(sizeof(RadixSlot));
|
||||
descriptor->min=rs->keyLimit;
|
||||
|
@ -57,7 +57,7 @@ RadixItem **radixsort_get_slot(RadixSorter *rs, unsigned topIndex)
|
|||
return slot;
|
||||
}
|
||||
|
||||
void radixsort_add(RadixSorter *rs, RadixItem *item)
|
||||
void radixsort_add(RadixSorter* rs, RadixItem* item)
|
||||
{
|
||||
if(item->key > rs->keyLimit) {
|
||||
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);
|
||||
}
|
||||
|
||||
RadixItem *chain=rs->topDigits[topIndex][lowIndex];
|
||||
RadixItem* chain=rs->topDigits[topIndex][lowIndex];
|
||||
rs->topDigits[topIndex][lowIndex]=item;
|
||||
if(chain==NULL) {
|
||||
item->next=NULL;
|
||||
|
@ -96,7 +96,7 @@ void radixsort_add(RadixSorter *rs, RadixItem *item)
|
|||
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);
|
||||
|
||||
|
@ -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
|
||||
if(key <= rs->maxKey) {
|
||||
|
@ -151,7 +151,7 @@ RadixItem *radix_cut(RadixSorter *rs, unsigned key, void *data)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
RadixItem **radixsort_dump(RadixSorter *rs)
|
||||
RadixItem** radixsort_dump(RadixSorter* rs)
|
||||
{
|
||||
if(rs->size>0) {
|
||||
RadixItem **result=malloc(rs->size * sizeof(RadixItem *));
|
||||
|
@ -185,7 +185,7 @@ RadixItem **radixsort_dump(RadixSorter *rs)
|
|||
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);
|
||||
unsigned memory=rs->_topIndexLimit * sizeof(RadixItem ***);
|
||||
|
@ -226,7 +226,7 @@ void radixsort_stat(RadixSorter *rs, bool listing)
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
void radixsort_destroy(RadixSorter *rs)
|
||||
void radixsort_destroy(RadixSorter* rs)
|
||||
{
|
||||
// radix items: DONE (passed on dump() by reference)
|
||||
// rs: DONE (created and destroyed by caller)
|
||||
|
|
Loading…
Add table
Reference in a new issue