summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Salfischberger <tomas@rockbox.org>2005-05-02 23:09:21 +0000
committerTomas Salfischberger <tomas@rockbox.org>2005-05-02 23:09:21 +0000
commit84364bc4ff17fa9a87f48c680e1d5d826b637a59 (patch)
tree05f6b919494fcd207b80f9227eca48419a1091ad
parent8485901c3f9b0ae365e8972b0968ab556ec137f3 (diff)
downloadrockbox-84364bc4ff17fa9a87f48c680e1d5d826b637a59.tar.gz
rockbox-84364bc4ff17fa9a87f48c680e1d5d826b637a59.zip
Moved some data from stack to pluginbuffer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6400 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/dict.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c
index d3fea1d52d..5aaa86a000 100644
--- a/apps/plugins/dict.c
+++ b/apps/plugins/dict.c
@@ -26,7 +26,6 @@ static int display_columns, display_lines;
26 26
27/* Some lenghts */ 27/* Some lenghts */
28#define WORDLEN 32 /* has to be the same in rdf2binary.c */ 28#define WORDLEN 32 /* has to be the same in rdf2binary.c */
29#define DESCLEN 2048
30 29
31/* The word struct :) */ 30/* The word struct :) */
32struct stWord 31struct stWord
@@ -51,6 +50,33 @@ void init_screen(void)
51#endif 50#endif
52} 51}
53 52
53/* global vars for pl_malloc() */
54void *bufptr;
55int bufleft;
56
57/* simple function to "allocate" memory in pluginbuffer. */
58void *pl_malloc(int size)
59{
60 void *ptr;
61 ptr = bufptr;
62
63 if (bufleft < size)
64 {
65 return NULL;
66 }
67 else
68 {
69 bufptr += size;
70 return ptr;
71 }
72}
73
74/* init function for pl_malloc() */
75void pl_malloc_init(void)
76{
77 bufptr = rb->plugin_get_buffer(&bufleft);
78}
79
54/* for endian problems */ 80/* for endian problems */
55#ifdef ROCKBOX_BIG_ENDIAN 81#ifdef ROCKBOX_BIG_ENDIAN
56#define readlong(x) x 82#define readlong(x) x
@@ -74,8 +100,8 @@ long readlong(void* value)
74enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 100enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
75{ 101{
76 char searchword[WORDLEN]; /* word to search for */ 102 char searchword[WORDLEN]; /* word to search for */
77 char description[DESCLEN]; /* description buffer */ 103 char *description; /* pointer to description buffer */
78 char output[DESCLEN]; /* output buffer */ 104 char *output; /* pointer to output buffer */
79 char *ptr, *space; 105 char *ptr, *space;
80 struct stWord word; /* the struct to read into */ 106 struct stWord word; /* the struct to read into */
81 int fIndex, fData; /* files */ 107 int fIndex, fData; /* files */
@@ -90,6 +116,25 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
90 /* get screen info */ 116 /* get screen info */
91 init_screen(); 117 init_screen();
92 118
119 /* get pl_malloc() buffer ready. */
120 pl_malloc_init();
121
122 /* init description buffer (size is because we don't have scrolling)*/
123 description = (char *)pl_malloc(display_columns * display_lines);
124 if (description == NULL)
125 {
126 DEBUGF("Err: failed to allocate description buffer.");
127 return PLUGIN_ERROR;
128 }
129
130 /* init output buffer */
131 output = (char *)pl_malloc(display_columns);
132 if (output == NULL)
133 {
134 DEBUGF("Err: failed to allocate output buffer.");
135 return PLUGIN_ERROR;
136 }
137
93 /* "clear" input buffer */ 138 /* "clear" input buffer */
94 searchword[0] = '\0'; 139 searchword[0] = '\0';
95 140
@@ -160,7 +205,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
160 rb->lseek(fData, readlong(&word.offset), SEEK_SET); 205 rb->lseek(fData, readlong(&word.offset), SEEK_SET);
161 206
162 /* Read in the description */ 207 /* Read in the description */
163 rb->read_line(fData, description, DESCLEN); 208 rb->read_line(fData, description, display_columns * display_lines);
164 209
165 /* And print it to debug. */ 210 /* And print it to debug. */
166 DEBUGF("Description: %s\n", description); 211 DEBUGF("Description: %s\n", description);