diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-12 00:05:00 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-12 00:05:00 +0300 |
commit | f569a6f2628b9ddef4dfb4424aff2dad644a8f19 (patch) | |
tree | 6d6e5b03bc97198c2002703591fe5e751978130c /src/txtacc.c | |
parent | 590e208c40797206fd6a93651fc59e0b68eeb545 (diff) | |
download | wydawca-f569a6f2628b9ddef4dfb4424aff2dad644a8f19.tar.gz wydawca-f569a6f2628b9ddef4dfb4424aff2dad644a8f19.tar.bz2 |
Improve the txtacc interface.
Diffstat (limited to 'src/txtacc.c')
-rw-r--r-- | src/txtacc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/txtacc.c b/src/txtacc.c index c094c22..91659f6 100644 --- a/src/txtacc.c +++ b/src/txtacc.c | |||
@@ -121,11 +121,12 @@ txtacc_grow (struct txtacc *acc, const char *buf, size_t size) | |||
121 | } | 121 | } |
122 | 122 | ||
123 | char * | 123 | char * |
124 | txtacc_finish (struct txtacc *acc) | 124 | txtacc_finish (struct txtacc *acc, int steal) |
125 | { | 125 | { |
126 | struct grecs_list_entry *ep; | 126 | struct grecs_list_entry *ep; |
127 | struct txtacc_entry *txtent; | 127 | struct txtacc_entry *txtent; |
128 | size_t size; | 128 | size_t size; |
129 | char *p; | ||
129 | 130 | ||
130 | switch (grecs_list_size (acc->cur)) | 131 | switch (grecs_list_size (acc->cur)) |
131 | { | 132 | { |
@@ -135,7 +136,6 @@ txtacc_finish (struct txtacc *acc) | |||
135 | case 1: | 136 | case 1: |
136 | txtent = acc->cur->head->data; | 137 | txtent = acc->cur->head->data; |
137 | acc->cur->head->data = NULL; | 138 | acc->cur->head->data = NULL; |
138 | grecs_list_append (acc->mem, txtent); | ||
139 | txtacc_entry_tailor (txtent); | 139 | txtacc_entry_tailor (txtent); |
140 | break; | 140 | break; |
141 | 141 | ||
@@ -156,7 +156,12 @@ txtacc_finish (struct txtacc *acc) | |||
156 | } | 156 | } |
157 | 157 | ||
158 | grecs_list_clear (acc->cur); | 158 | grecs_list_clear (acc->cur); |
159 | return txtent->buf; | 159 | p = txtent->buf; |
160 | if (steal) | ||
161 | free (txtent); | ||
162 | else | ||
163 | grecs_list_append (acc->mem, txtent); | ||
164 | return p; | ||
160 | } | 165 | } |
161 | 166 | ||
162 | void | 167 | void |