File src/hashset.c changed (mode: 100644) (index bf32eec..b73f8fd) |
... |
... |
void *hashset_get(const HashSet * hs, const char *key) |
37 |
37 |
int listNum = hashmap_hash( key ); |
int listNum = hashmap_hash( key ); |
38 |
38 |
struct HashSetNode *ptr = hs->lists[ listNum ]; |
struct HashSetNode *ptr = hs->lists[ listNum ]; |
39 |
39 |
|
|
40 |
|
while( ptr != NULL && strcmp( ptr->key, key ) != 0 ) |
|
|
40 |
|
while(ptr != NULL && strcmp(ptr->key, key)!= 0) { |
41 |
41 |
ptr = ptr->next; |
ptr = ptr->next; |
|
42 |
|
} |
42 |
43 |
|
|
43 |
|
return (ptr != NULL? ptr->value : NULL); |
|
|
44 |
|
return (ptr!=NULL?ptr->value:NULL); |
44 |
45 |
} |
} |
45 |
46 |
|
|
46 |
47 |
int hashset_contains(const HashSet * hs, const char *key) |
int hashset_contains(const HashSet * hs, const char *key) |
|
... |
... |
int hashset_put(HashSet *hs, const char *key, void *value) |
52 |
53 |
{ |
{ |
53 |
54 |
if(hashset_get(hs, key)) { |
if(hashset_get(hs, key)) { |
54 |
55 |
return 0; |
return 0; |
55 |
|
} |
|
56 |
|
|
|
57 |
|
int listNum = hashmap_hash( key ); |
|
58 |
|
struct HashSetNode *newNode=(struct HashSetNode *)malloc(sizeof(struct HashSetNode)); |
|
59 |
|
if(newNode == NULL) { |
|
60 |
|
fprintf(stderr,"Unable to allocate hashset entry!"); |
|
61 |
|
return 0; |
|
62 |
|
} |
|
|
56 |
|
} else { |
|
57 |
|
int listNum = hashmap_hash( key ); |
|
58 |
|
struct HashSetNode *newNode=(struct HashSetNode *)malloc(sizeof(struct HashSetNode)); |
|
59 |
|
if(newNode == NULL) { |
|
60 |
|
fprintf(stderr,"Unable to allocate hashset entry!"); |
|
61 |
|
return 0; |
|
62 |
|
} |
63 |
63 |
|
|
64 |
|
newNode->key=malloc(strlen(key)+1); |
|
65 |
|
strcpy(newNode->key, key); |
|
66 |
|
newNode->value=value; |
|
67 |
|
newNode->next=hs->lists[listNum]; |
|
68 |
|
hs->lists[listNum]=newNode; |
|
69 |
|
hs->currentSize++; |
|
|
64 |
|
newNode->key=malloc(strlen(key)+1); |
|
65 |
|
strcpy(newNode->key, key); |
|
66 |
|
newNode->value=value; |
|
67 |
|
newNode->next=hs->lists[listNum]; |
|
68 |
|
hs->lists[listNum]=newNode; |
|
69 |
|
hs->currentSize++; |
70 |
70 |
|
|
71 |
|
return 1; |
|
|
71 |
|
return 1; |
|
72 |
|
} |
72 |
73 |
} |
} |
73 |
74 |
|
|
74 |
75 |
int hashset_add(HashSet * hs, const char *key) |
int hashset_add(HashSet * hs, const char *key) |
File src/hstr.c changed (mode: 100644) (index 6e1a46d..e938e09) |
... |
... |
void loop_to_select(Hstr *hstr) |
782 |
782 |
hstr_next_view(hstr); |
hstr_next_view(hstr); |
783 |
783 |
result=hstr_print_selection(maxHistoryItems, pattern, hstr); |
result=hstr_print_selection(maxHistoryItems, pattern, hstr); |
784 |
784 |
print_history_label(hstr); |
print_history_label(hstr); |
|
785 |
|
// TODO function |
785 |
786 |
selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; |
selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; |
786 |
787 |
if(strlen(pattern)<(width-basex-1)) { |
if(strlen(pattern)<(width-basex-1)) { |
787 |
788 |
print_prefix(pattern, y, basex); |
print_prefix(pattern, y, basex); |
|
... |
... |
void loop_to_select(Hstr *hstr) |
802 |
803 |
} |
} |
803 |
804 |
result=hstr_print_selection(maxHistoryItems, pattern, hstr); |
result=hstr_print_selection(maxHistoryItems, pattern, hstr); |
804 |
805 |
selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; |
selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; |
|
806 |
|
// TODO code review |
|
807 |
|
if(strlen(pattern)<(width-basex-1)) { |
|
808 |
|
print_prefix(pattern, y, basex); |
|
809 |
|
cursorX=getcurx(stdscr); |
|
810 |
|
cursorY=getcury(stdscr); |
|
811 |
|
} |
805 |
812 |
} |
} |
806 |
813 |
break; |
break; |
807 |
814 |
case KEY_RESIZE: |
case KEY_RESIZE: |
File src/hstr_favorites.c changed (mode: 100644) (index 0526ce6..77055c7) |
... |
... |
void favorites_destroy(FavoriteItems *favorites) |
191 |
191 |
for(i=0; i<favorites->count; i++) { |
for(i=0; i<favorites->count; i++) { |
192 |
192 |
free(favorites->items[i]); |
free(favorites->items[i]); |
193 |
193 |
} |
} |
194 |
|
hashset_destroy(&favorites->set, false); |
|
|
194 |
|
hashset_destroy(favorites->set, false); |
195 |
195 |
free(favorites); |
free(favorites); |
196 |
196 |
} |
} |
197 |
197 |
} |
} |