summaryrefslogtreecommitdiff
path: root/word.c
diff options
context:
space:
mode:
authorb0ric <b0risov.alexandr@rambler.ru>2009-08-10 01:08:31 +0300
committerb0ric <b0risov.alexandr@rambler.ru>2009-08-10 01:08:31 +0300
commitd2b347e0aa6e5fc3de95253c43900c15938dbaaf (patch)
tree8f7a3a2756e9cf5292348170a45d971dc061b871 /word.c
parent343357ed1e7907cf4b488058053df280ae63c7bb (diff)
Interface modification and improvement. Lecense changed to GPLv3
Diffstat (limited to 'word.c')
-rw-r--r--word.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/word.c b/word.c
index 9f16695..0e84ae2 100644
--- a/word.c
+++ b/word.c
@@ -20,7 +20,6 @@
#include <stdlib.h>
#include <string.h>
#include "mainwin.h"
-#include "listview.h"
#include "word.h"
#include "dict.h"
@@ -31,6 +30,20 @@ static void sort_words(const Word *);
static inline char *wordcpy(char *);
static inline void free_word_record(Word *);
+unsigned int get_words_count(const Word *root)
+{
+ unsigned int cnt = 0;
+
+ if (root == NULL)
+ return 0;
+ else {
+ cnt += get_words_count(root->lsibl);
+ cnt += get_words_count(root->rsibl);
+ cnt++;
+ return cnt;
+ }
+}
+
int to_list(char *word)
{
if (!is_in_dict(word, dict)) {
@@ -58,13 +71,13 @@ Word *add_word_record(Word *root, char *word)
return root;
}
-char **get_sorted()
+char **get_sorted(Word *root)
{
unsigned int cnt;
- cnt = get_words_count(words);
+ cnt = get_words_count(root);
sorted = malloc(cnt*sizeof(char*));
- sort_words(words);
+ sort_words(root);
return (sorted - cnt);
}
@@ -78,20 +91,6 @@ static void sort_words(const Word *root)
sort_words(root->rsibl);
}
-unsigned int get_words_count(const Word *root)
-{
- unsigned int cnt = 0;
-
- if (root == NULL)
- return 0;
- else {
- cnt += get_words_count(root->lsibl);
- cnt += get_words_count(root->rsibl);
- cnt++;
- return cnt;
- }
-}
-
void free_words(Word *root)
{
if (root->lsibl != NULL)
@@ -101,15 +100,6 @@ void free_words(Word *root)
free_word_record(root);
}
-void print_words(Word *root)
-{
- if (root != NULL) {
- print_words(root->lsibl);
- print_words(root->rsibl);
- add_word_to_list(root->word);
- }
-}
-
static inline void free_word_record(Word *record)
{
free(record->word);