Commit 78f92501 78f92501613a377b4c5bb2680dc071e928a96855 by Sergey Poznyakoff

Remove dependency on obstack. Use mu_opool_t instead.

* include/mailutils/opool.h (mu_opool_alloc): New proto.
* libmailutils/base/opool.c (mu_opool_alloc): New function.
(mu_opool_appendz): Do not append trailing null character.
* libmailutils/cfg/parser.y (mu_cfg_tree_create_node): Reflect
the change in mu_opool_appendz.
* comsat/action.c: Use mu_opool_t instead of struct obstack.
* lib/mailcap.c: Likewise.
* libmailutils/url/urlstr.c: Likewise.
* mh/burst.c: Likewise.
* mh/mh_fmtgram.y: Likewise.
* mh/mh_format.c: Likewise.
* mh/mh_format.h: Likewise.
* mh/mhn.c: Likewise.
* mh/repl.c: Likewise.
* mh/whatnowenv.c: Likewise.
* mimeview/mimetypes.l: Likewise.
* mimeview/mimeview.h: Likewise.

* gnulib.modules: Remove obstack.
1 parent e9871d0f
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
19 #include <mailutils/io.h> 19 #include <mailutils/io.h>
20 #include <mailutils/argcv.h> 20 #include <mailutils/argcv.h>
21 #include <mailutils/prog.h> 21 #include <mailutils/prog.h>
22 #define obstack_chunk_alloc malloc 22 #include <mailutils/opool.h>
23 #define obstack_chunk_free free
24 #include <obstack.h>
25 23
26 /* This module implements user-configurable actions for comsat. The 24 /* This module implements user-configurable actions for comsat. The
27 actions are kept in file .biffrc in the user's home directory and 25 actions are kept in file .biffrc in the user's home directory and
...@@ -42,7 +40,7 @@ ...@@ -42,7 +40,7 @@
42 When omitted, they default to 400, 5. */ 40 When omitted, they default to 400, 5. */
43 41
44 static int 42 static int
45 expand_escape (char **pp, mu_message_t msg, struct obstack *stk) 43 expand_escape (char **pp, mu_message_t msg, mu_opool_t pool)
46 { 44 {
47 char *p = *pp; 45 char *p = *pp;
48 char *start, *sval, *namep; 46 char *start, *sval, *namep;
...@@ -56,15 +54,13 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk) ...@@ -56,15 +54,13 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
56 switch (*++p) /* skip past $ */ 54 switch (*++p) /* skip past $ */
57 { 55 {
58 case 'u': 56 case 'u':
59 len = strlen (username); 57 mu_opool_appendz (pool, username);
60 obstack_grow (stk, username, len);
61 *pp = p; 58 *pp = p;
62 rc = 0; 59 rc = 0;
63 break; 60 break;
64 61
65 case 'h': 62 case 'h':
66 len = strlen (hostname); 63 mu_opool_appendz (pool, hostname);
67 obstack_grow (stk, hostname, len);
68 *pp = p; 64 *pp = p;
69 rc = 0; 65 rc = 0;
70 break; 66 break;
...@@ -85,10 +81,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk) ...@@ -85,10 +81,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
85 namep[len] = 0; 81 namep[len] = 0;
86 if (mu_message_get_header (msg, &hdr) == 0 82 if (mu_message_get_header (msg, &hdr) == 0
87 && mu_header_aget_value (hdr, namep, &sval) == 0) 83 && mu_header_aget_value (hdr, namep, &sval) == 0)
88 { 84 mu_opool_appendz (pool, sval);
89 len = strlen (sval);
90 obstack_grow (stk, sval, len);
91 }
92 free (namep); 85 free (namep);
93 *pp = p; 86 *pp = p;
94 rc = 0; 87 rc = 0;
...@@ -131,7 +124,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk) ...@@ -131,7 +124,7 @@ expand_escape (char **pp, mu_message_t msg, struct obstack *stk)
131 size += s - q + 1; 124 size += s - q + 1;
132 q = s + 1; 125 q = s + 1;
133 } 126 }
134 obstack_grow (stk, buf, size); 127 mu_opool_append (pool, buf, size);
135 } 128 }
136 mu_stream_destroy (&stream); 129 mu_stream_destroy (&stream);
137 free (buf); 130 free (buf);
...@@ -147,11 +140,11 @@ expand_line (const char *str, mu_message_t msg) ...@@ -147,11 +140,11 @@ expand_line (const char *str, mu_message_t msg)
147 { 140 {
148 const char *p; 141 const char *p;
149 int c = 0; 142 int c = 0;
150 struct obstack stk; 143 mu_opool_t pool;
151 144
152 if (!*str) 145 if (!*str)
153 return NULL; 146 return NULL;
154 obstack_init (&stk); 147 mu_opool_create (&pool, 1);
155 for (p = str; *p; p++) 148 for (p = str; *p; p++)
156 { 149 {
157 switch (*p) 150 switch (*p)
...@@ -161,22 +154,22 @@ expand_line (const char *str, mu_message_t msg) ...@@ -161,22 +154,22 @@ expand_line (const char *str, mu_message_t msg)
161 if (*p) 154 if (*p)
162 { 155 {
163 c = mu_wordsplit_c_unquote_char (*p); 156 c = mu_wordsplit_c_unquote_char (*p);
164 obstack_1grow (&stk, c); 157 mu_opool_append_char (pool, c);
165 } 158 }
166 break; 159 break;
167 160
168 case '$': 161 case '$':
169 if (expand_escape ((char**)&p, msg, &stk) == 0) 162 if (expand_escape ((char**)&p, msg, pool) == 0)
170 break; 163 break;
171 164
172 /*FALLTHRU*/ 165 /*FALLTHRU*/
173 default: 166 default:
174 obstack_1grow (&stk, *p); 167 mu_opool_append_char (pool, *p);
175 } 168 }
176 } 169 }
177 obstack_1grow (&stk, 0); 170 mu_opool_append_char (pool, 0);
178 str = strdup (obstack_finish (&stk)); 171 str = strdup (mu_opool_finish (pool, NULL));
179 obstack_free (&stk, NULL); 172 mu_opool_destroy (&pool);
180 return (char *)str; 173 return (char *)str;
181 } 174 }
182 175
......
...@@ -14,6 +14,5 @@ mbchar ...@@ -14,6 +14,5 @@ mbchar
14 mbiter 14 mbiter
15 mbslen 15 mbslen
16 mbswidth 16 mbswidth
17 obstack
18 setenv 17 setenv
19 stdint 18 stdint
......
...@@ -42,6 +42,9 @@ void mu_opool_clear (mu_opool_t opool); ...@@ -42,6 +42,9 @@ void mu_opool_clear (mu_opool_t opool);
42 /* Destroy the pool, reclaim any memory associated with it. */ 42 /* Destroy the pool, reclaim any memory associated with it. */
43 void mu_opool_destroy (mu_opool_t *popool); 43 void mu_opool_destroy (mu_opool_t *popool);
44 44
45 /* Allocate SIZE bytes in the pool. */
46 int mu_opool_alloc (mu_opool_t opool, size_t size);
47
45 /* Append to the current object N bytes pointed to by STR. */ 48 /* Append to the current object N bytes pointed to by STR. */
46 int mu_opool_append (mu_opool_t opool, const void *str, size_t n); 49 int mu_opool_append (mu_opool_t opool, const void *str, size_t n);
47 50
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
19 #endif 19 #endif
20 #include <mailutils/mailutils.h> 20 #include <mailutils/mailutils.h>
21 #include <fnmatch.h> 21 #include <fnmatch.h>
22 #define obstack_chunk_alloc malloc
23 #define obstack_chunk_free free
24 #include <obstack.h>
25 #include <sys/wait.h> 22 #include <sys/wait.h>
26 #include <ctype.h> 23 #include <ctype.h>
27 24
...@@ -241,7 +238,7 @@ mime_context_get_temp_file (struct mime_context *ctx, char **ptr) ...@@ -241,7 +238,7 @@ mime_context_get_temp_file (struct mime_context *ctx, char **ptr)
241 } 238 }
242 239
243 240
244 static struct obstack expand_stack; 241 static mu_opool_t expand_pool;
245 242
246 static int 243 static int
247 expand_string (struct mime_context *ct, char **pstr) 244 expand_string (struct mime_context *ct, char **pstr)
...@@ -258,14 +255,14 @@ expand_string (struct mime_context *ct, char **pstr) ...@@ -258,14 +255,14 @@ expand_string (struct mime_context *ct, char **pstr)
258 { 255 {
259 case 's': 256 case 's':
260 mime_context_get_temp_file (ct, &s); 257 mime_context_get_temp_file (ct, &s);
261 obstack_grow (&expand_stack, s, strlen (s)); 258 mu_opool_appendz (expand_pool, s);
262 rc = 1; 259 rc = 1;
263 p += 2; 260 p += 2;
264 break; 261 break;
265 262
266 case 't': 263 case 't':
267 mime_context_get_content_type (ct, &s); 264 mime_context_get_content_type (ct, &s);
268 obstack_grow (&expand_stack, s, strlen (s)); 265 mu_opool_appendz (expand_pool, s);
269 p += 2; 266 p += 2;
270 break; 267 break;
271 268
...@@ -281,7 +278,7 @@ expand_string (struct mime_context *ct, char **pstr) ...@@ -281,7 +278,7 @@ expand_string (struct mime_context *ct, char **pstr)
281 if (mime_context_get_content_type_value (ct, 278 if (mime_context_get_content_type_value (ct,
282 q, p-q, 279 q, p-q,
283 &s, &n) == 0) 280 &s, &n) == 0)
284 obstack_grow (&expand_stack, s, n); 281 mu_opool_append (expand_pool, s, n);
285 if (*p) 282 if (*p)
286 p++; 283 p++;
287 break; 284 break;
...@@ -293,19 +290,19 @@ expand_string (struct mime_context *ct, char **pstr) ...@@ -293,19 +290,19 @@ expand_string (struct mime_context *ct, char **pstr)
293 break; 290 break;
294 291
295 default: 292 default:
296 obstack_1grow (&expand_stack, p[0]); 293 mu_opool_append_char (expand_pool, p[0]);
297 } 294 }
298 break; 295 break;
299 296
300 case '\\': 297 case '\\':
301 if (p[1]) 298 if (p[1])
302 { 299 {
303 obstack_1grow (&expand_stack, p[1]); 300 mu_opool_append_char (expand_pool, p[1]);
304 p += 2; 301 p += 2;
305 } 302 }
306 else 303 else
307 { 304 {
308 obstack_1grow (&expand_stack, p[0]); 305 mu_opool_append_char (expand_pool, p[0]);
309 p++; 306 p++;
310 } 307 }
311 break; 308 break;
...@@ -313,23 +310,23 @@ expand_string (struct mime_context *ct, char **pstr) ...@@ -313,23 +310,23 @@ expand_string (struct mime_context *ct, char **pstr)
313 case '"': 310 case '"':
314 if (p[1] == p[0]) 311 if (p[1] == p[0])
315 { 312 {
316 obstack_1grow (&expand_stack, '%'); 313 mu_opool_append_char (expand_pool, '%');
317 p++; 314 p++;
318 } 315 }
319 else 316 else
320 { 317 {
321 obstack_1grow (&expand_stack, p[0]); 318 mu_opool_append_char (expand_pool, p[0]);
322 p++; 319 p++;
323 } 320 }
324 break; 321 break;
325 322
326 default: 323 default:
327 obstack_1grow (&expand_stack, p[0]); 324 mu_opool_append_char (expand_pool, p[0]);
328 p++; 325 p++;
329 } 326 }
330 } 327 }
331 obstack_1grow (&expand_stack, 0); 328 mu_opool_append_char (expand_pool, 0);
332 *pstr = obstack_finish (&expand_stack); 329 *pstr = mu_opool_finish (expand_pool, NULL);
333 return rc; 330 return rc;
334 } 331 }
335 332
...@@ -514,8 +511,8 @@ run_test (mu_mailcap_entry_t entry, struct mime_context *ctx) ...@@ -514,8 +511,8 @@ run_test (mu_mailcap_entry_t entry, struct mime_context *ctx)
514 struct mu_wordsplit ws; 511 struct mu_wordsplit ws;
515 char *str; 512 char *str;
516 513
517 obstack_blank (&expand_stack, size + 1); 514 mu_opool_alloc (expand_pool, size + 1);
518 str = obstack_finish (&expand_stack); 515 str = mu_opool_finish (expand_pool, NULL);
519 mu_mailcap_entry_get_test (entry, str, size + 1, NULL); 516 mu_mailcap_entry_get_test (entry, str, size + 1, NULL);
520 517
521 expand_string (ctx, &str); 518 expand_string (ctx, &str);
...@@ -556,8 +553,8 @@ run_mailcap (mu_mailcap_entry_t entry, struct mime_context *ctx) ...@@ -556,8 +553,8 @@ run_mailcap (mu_mailcap_entry_t entry, struct mime_context *ctx)
556 if (mu_mailcap_entry_get_viewcommand (entry, NULL, 0, &size)) 553 if (mu_mailcap_entry_get_viewcommand (entry, NULL, 0, &size))
557 return 1; 554 return 1;
558 size++; 555 size++;
559 obstack_blank (&expand_stack, size); 556 mu_opool_alloc (expand_pool, size);
560 view_command = obstack_finish (&expand_stack); 557 view_command = mu_opool_finish (expand_pool, NULL);
561 mu_mailcap_entry_get_viewcommand (entry, view_command, size, NULL); 558 mu_mailcap_entry_get_viewcommand (entry, view_command, size, NULL);
562 } 559 }
563 else 560 else
...@@ -565,8 +562,8 @@ run_mailcap (mu_mailcap_entry_t entry, struct mime_context *ctx) ...@@ -565,8 +562,8 @@ run_mailcap (mu_mailcap_entry_t entry, struct mime_context *ctx)
565 if (mu_mailcap_entry_get_value (entry, "print", NULL, 0, &size)) 562 if (mu_mailcap_entry_get_value (entry, "print", NULL, 0, &size))
566 return 1; 563 return 1;
567 size++; 564 size++;
568 obstack_blank (&expand_stack, size); 565 mu_opool_alloc (expand_pool, size);
569 view_command = obstack_finish (&expand_stack); 566 view_command = mu_opool_finish (expand_pool, NULL);
570 mu_mailcap_entry_get_value (entry, "print", view_command, size, NULL); 567 mu_mailcap_entry_get_value (entry, "print", view_command, size, NULL);
571 } 568 }
572 569
...@@ -691,7 +688,7 @@ display_stream_mailcap (const char *ident, mu_stream_t stream, mu_header_t hdr, ...@@ -691,7 +688,7 @@ display_stream_mailcap (const char *ident, mu_stream_t stream, mu_header_t hdr,
691 mailcap_path = mailcap_path_tmp; 688 mailcap_path = mailcap_path_tmp;
692 } 689 }
693 690
694 obstack_init (&expand_stack); 691 mu_opool_create (&expand_pool, 1);
695 692
696 ws.ws_delim = ":"; 693 ws.ws_delim = ":";
697 if (mu_wordsplit (mailcap_path, &ws, 694 if (mu_wordsplit (mailcap_path, &ws,
...@@ -712,7 +709,7 @@ display_stream_mailcap (const char *ident, mu_stream_t stream, mu_header_t hdr, ...@@ -712,7 +709,7 @@ display_stream_mailcap (const char *ident, mu_stream_t stream, mu_header_t hdr,
712 } 709 }
713 mu_wordsplit_free (&ws); 710 mu_wordsplit_free (&ws);
714 } 711 }
715 obstack_free (&expand_stack, NULL); 712 mu_opool_destroy (&expand_pool);
716 free (mailcap_path_tmp); 713 free (mailcap_path_tmp);
717 mime_context_release (&ctx); 714 mime_context_release (&ctx);
718 return rc; 715 return rc;
......
...@@ -168,6 +168,25 @@ mu_opool_destroy (mu_opool_t *popool) ...@@ -168,6 +168,25 @@ mu_opool_destroy (mu_opool_t *popool)
168 } 168 }
169 169
170 int 170 int
171 mu_opool_alloc (mu_opool_t opool, size_t size)
172 {
173 while (size)
174 {
175 size_t rest;
176
177 if (!opool->head || opool->tail->level == opool->tail->size)
178 if (alloc_pool (opool, opool->bucket_size))
179 return ENOMEM;
180 rest = opool->tail->size - opool->tail->level;
181 if (size < rest)
182 rest = size;
183 opool->tail->level += rest;
184 size -= rest;
185 }
186 return 0;
187 }
188
189 int
171 mu_opool_append (mu_opool_t opool, const void *str, size_t n) 190 mu_opool_append (mu_opool_t opool, const void *str, size_t n)
172 { 191 {
173 const char *ptr = str; 192 const char *ptr = str;
...@@ -191,8 +210,7 @@ mu_opool_append_char (mu_opool_t opool, char c) ...@@ -191,8 +210,7 @@ mu_opool_append_char (mu_opool_t opool, char c)
191 int 210 int
192 mu_opool_appendz (mu_opool_t opool, const char *str) 211 mu_opool_appendz (mu_opool_t opool, const char *str)
193 { 212 {
194 return mu_opool_append (opool, str, strlen (str)) 213 return mu_opool_append (opool, str, strlen (str));
195 || mu_opool_append_char (opool, 0);
196 } 214 }
197 215
198 size_t 216 size_t
......
...@@ -1475,6 +1475,7 @@ mu_cfg_tree_create_node (struct mu_cfg_tree *tree, ...@@ -1475,6 +1475,7 @@ mu_cfg_tree_create_node (struct mu_cfg_tree *tree,
1475 { 1475 {
1476 mu_opool_clear (tree->pool); 1476 mu_opool_clear (tree->pool);
1477 mu_opool_appendz (tree->pool, label); 1477 mu_opool_appendz (tree->pool, label);
1478 mu_opool_append_char (tree->pool, 0);
1478 val.v.string = mu_opool_finish (tree->pool, NULL); 1479 val.v.string = mu_opool_finish (tree->pool, NULL);
1479 np->label = config_value_dup (&val); 1480 np->label = config_value_dup (&val);
1480 } 1481 }
......
...@@ -35,27 +35,27 @@ url_reconstruct_to_pool (mu_url_t url, mu_opool_t pool) ...@@ -35,27 +35,27 @@ url_reconstruct_to_pool (mu_url_t url, mu_opool_t pool)
35 { 35 {
36 int i; 36 int i;
37 37
38 mu_opool_append (pool, url->scheme, strlen (url->scheme)); 38 mu_opool_appendz (pool, url->scheme);
39 mu_opool_append (pool, "://", 3); 39 mu_opool_append (pool, "://", 3);
40 40
41 if (url->flags & MU_URL_USER) 41 if (url->flags & MU_URL_USER)
42 mu_opool_append (pool, url->user, strlen (url->user)); 42 mu_opool_appendz (pool, url->user);
43 if (url->flags & MU_URL_SECRET) 43 if (url->flags & MU_URL_SECRET)
44 mu_opool_append (pool, ":***", 4); /* FIXME: How about MU_URL_PARSE_HIDEPASS? */ 44 mu_opool_append (pool, ":***", 4); /* FIXME: How about MU_URL_PARSE_HIDEPASS? */
45 if (url->flags & MU_URL_AUTH) 45 if (url->flags & MU_URL_AUTH)
46 { 46 {
47 mu_opool_append (pool, AUTH_PFX, sizeof AUTH_PFX - 1); 47 mu_opool_append (pool, AUTH_PFX, sizeof AUTH_PFX - 1);
48 mu_opool_append (pool, url->auth, strlen (url->auth)); 48 mu_opool_appendz (pool, url->auth);
49 } 49 }
50 if (url->flags & MU_URL_HOST) 50 if (url->flags & MU_URL_HOST)
51 { 51 {
52 if (url->flags & (MU_URL_USER|MU_URL_SECRET|MU_URL_AUTH)) 52 if (url->flags & (MU_URL_USER|MU_URL_SECRET|MU_URL_AUTH))
53 mu_opool_append_char (pool, '@'); 53 mu_opool_append_char (pool, '@');
54 mu_opool_append (pool, url->host, strlen (url->host)); 54 mu_opool_appendz (pool, url->host);
55 if (url->flags & MU_URL_PORT) 55 if (url->flags & MU_URL_PORT)
56 { 56 {
57 mu_opool_append_char (pool, ':'); 57 mu_opool_append_char (pool, ':');
58 mu_opool_append (pool, url->portstr, strlen (url->portstr)); 58 mu_opool_appendz (pool, url->portstr);
59 } 59 }
60 } 60 }
61 else if (url->flags & (MU_URL_USER|MU_URL_SECRET|MU_URL_AUTH)) 61 else if (url->flags & (MU_URL_USER|MU_URL_SECRET|MU_URL_AUTH))
...@@ -65,7 +65,7 @@ url_reconstruct_to_pool (mu_url_t url, mu_opool_t pool) ...@@ -65,7 +65,7 @@ url_reconstruct_to_pool (mu_url_t url, mu_opool_t pool)
65 { 65 {
66 if (url->flags & MU_URL_HOST) 66 if (url->flags & MU_URL_HOST)
67 mu_opool_append_char (pool, '/'); 67 mu_opool_append_char (pool, '/');
68 mu_opool_append (pool, url->path, strlen (url->path)); 68 mu_opool_appendz (pool, url->path);
69 } 69 }
70 70
71 if (url->flags & MU_URL_PARAM) 71 if (url->flags & MU_URL_PARAM)
...@@ -93,7 +93,7 @@ url_reconstruct_to_pool (mu_url_t url, mu_opool_t pool) ...@@ -93,7 +93,7 @@ url_reconstruct_to_pool (mu_url_t url, mu_opool_t pool)
93 } 93 }
94 else if (url->flags == MU_URL_PATH) 94 else if (url->flags == MU_URL_PATH)
95 { 95 {
96 mu_opool_append (pool, url->path, strlen (url->path)); 96 mu_opool_appendz (pool, url->path);
97 return 0; 97 return 0;
98 } 98 }
99 return MU_ERR_URL_MISS_PARTS; 99 return MU_ERR_URL_MISS_PARTS;
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
17 /* MH burst command */ 17 /* MH burst command */
18 18
19 #include <mh.h> 19 #include <mh.h>
20 #define obstack_chunk_alloc malloc
21 #define obstack_chunk_free free
22 #include <obstack.h>
23 20
24 static char doc[] = N_("GNU MH burst")"\v" 21 static char doc[] = N_("GNU MH burst")"\v"
25 N_("Options marked with `*' are not yet implemented.\n\ 22 N_("Options marked with `*' are not yet implemented.\n\
...@@ -134,7 +131,7 @@ struct burst_map map; /* Currently built map */ ...@@ -134,7 +131,7 @@ struct burst_map map; /* Currently built map */
134 struct burst_map *burst_map; /* Finished burst map */ 131 struct burst_map *burst_map; /* Finished burst map */
135 size_t burst_count; /* Number of items in burst_map */ 132 size_t burst_count; /* Number of items in burst_map */
136 mu_mailbox_t tmpbox; /* Temporary mailbox */ 133 mu_mailbox_t tmpbox; /* Temporary mailbox */
137 struct obstack stk; /* Stack for building burst_map, etc. */ 134 mu_opool_t pool; /* Object pool for building burst_map, etc. */
138 135
139 static int burst_or_copy (mu_message_t msg, int recursive, int copy); 136 static int burst_or_copy (mu_message_t msg, int recursive, int copy);
140 137
...@@ -592,7 +589,7 @@ burst (size_t num, mu_message_t msg, void *data) ...@@ -592,7 +589,7 @@ burst (size_t num, mu_message_t msg, void *data)
592 mu_umaxtostr (1, num))); 589 mu_umaxtostr (1, num)));
593 if (inplace) 590 if (inplace)
594 { 591 {
595 obstack_grow (&stk, &map, sizeof map); 592 mu_opool_append (pool, &map, sizeof map);
596 burst_count++; 593 burst_count++;
597 } 594 }
598 } 595 }
...@@ -752,7 +749,7 @@ main (int argc, char **argv) ...@@ -752,7 +749,7 @@ main (int argc, char **argv)
752 mu_attribute_set_deleted (attr); 749 mu_attribute_set_deleted (attr);
753 } 750 }
754 mu_mailbox_expunge (tmpbox); 751 mu_mailbox_expunge (tmpbox);
755 obstack_init (&stk); 752 mu_opool_create (&pool, 1);
756 } 753 }
757 else 754 else
758 tmpbox = mbox; 755 tmpbox = mbox;
...@@ -769,7 +766,7 @@ main (int argc, char **argv) ...@@ -769,7 +766,7 @@ main (int argc, char **argv)
769 size_t count; 766 size_t count;
770 const char *dir; 767 const char *dir;
771 768
772 burst_map = obstack_finish (&stk); 769 burst_map = mu_opool_finish (pool, NULL);
773 770
774 mu_mailbox_uidnext (mbox, &next_uid); 771 mu_mailbox_uidnext (mbox, &next_uid);
775 for (i = 0, last_uid = next_uid-1; i < burst_count; i++) 772 for (i = 0, last_uid = next_uid-1; i < burst_count; i++)
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
17 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ 17 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
18 18
19 #include <mh.h> 19 #include <mh.h>
20 #define obstack_chunk_alloc malloc
21 #define obstack_chunk_free free
22 #include <obstack.h>
23 20
24 int yyerror (const char *s); 21 int yyerror (const char *s);
25 int yylex (); 22 int yylex ();
...@@ -27,7 +24,7 @@ int yylex (); ...@@ -27,7 +24,7 @@ int yylex ();
27 static mh_format_t format; /* Format structure being built */ 24 static mh_format_t format; /* Format structure being built */
28 static size_t pc; /* Program counter. Poins to current 25 static size_t pc; /* Program counter. Poins to current
29 cell in format.prog */ 26 cell in format.prog */
30 static struct obstack stack; /* Temporary token storage */ 27 static mu_opool_t tokpool; /* Temporary token storage */
31 28
32 #define FORMAT_INC 64 /* Increase format.prog by that many 29 #define FORMAT_INC 64 /* Increase format.prog by that many
33 cells each time pc reaches 30 cells each time pc reaches
...@@ -459,16 +456,16 @@ yylex () ...@@ -459,16 +456,16 @@ yylex ()
459 if (*curp == '\\') 456 if (*curp == '\\')
460 { 457 {
461 int c = backslash (*++curp); 458 int c = backslash (*++curp);
462 obstack_1grow (&stack, c); 459 mu_opool_append_char (tokpool, c);
463 } 460 }
464 else 461 else
465 obstack_1grow (&stack, *curp); 462 mu_opool_append_char (tokpool, *curp);
466 curp++; 463 curp++;
467 } 464 }
468 while (*curp && (expect_arg ? *curp != ')' : !isdelim(*curp))); 465 while (*curp && (expect_arg ? *curp != ')' : !isdelim(*curp)));
469 466
470 obstack_1grow (&stack, 0); 467 mu_opool_append_char (tokpool, 0);
471 yylval.str = obstack_finish (&stack); 468 yylval.str = mu_opool_finish (tokpool, NULL);
472 469
473 if (want_function) 470 if (want_function)
474 { 471 {
...@@ -502,7 +499,7 @@ mh_format_parse (char *format_str, mh_format_t *fmt) ...@@ -502,7 +499,7 @@ mh_format_parse (char *format_str, mh_format_t *fmt)
502 if (p) 499 if (p)
503 yydebug = 1; 500 yydebug = 1;
504 start = curp = format_str; 501 start = curp = format_str;
505 obstack_init (&stack); 502 mu_opool_create (&tokpool, 1);
506 format.prog = NULL; 503 format.prog = NULL;
507 format.progsize = 0; 504 format.progsize = 0;
508 pc = 0; 505 pc = 0;
...@@ -513,7 +510,7 @@ mh_format_parse (char *format_str, mh_format_t *fmt) ...@@ -513,7 +510,7 @@ mh_format_parse (char *format_str, mh_format_t *fmt)
513 510
514 rc = yyparse (); 511 rc = yyparse ();
515 mh_code_op (mhop_stop); 512 mh_code_op (mhop_stop);
516 obstack_free (&stack, NULL); 513 mu_opool_destroy (&tokpool);
517 if (rc) 514 if (rc)
518 { 515 {
519 mh_format_free (&format); 516 mh_format_free (&format);
......
...@@ -190,7 +190,7 @@ put_string (struct mh_machine *mach, char *str, int len) ...@@ -190,7 +190,7 @@ put_string (struct mh_machine *mach, char *str, int len)
190 { 190 {
191 if (len == 0) 191 if (len == 0)
192 return; 192 return;
193 obstack_grow (&mach->stk, str, len); 193 mu_opool_append (mach->pool, str, len);
194 len = mbsnwidth (str, len, 0); 194 len = mbsnwidth (str, len, 0);
195 mach->ind += len; 195 mach->ind += len;
196 } 196 }
...@@ -339,7 +339,7 @@ print_fmt_segment (struct mh_machine *mach, size_t fmtwidth, char *str, ...@@ -339,7 +339,7 @@ print_fmt_segment (struct mh_machine *mach, size_t fmtwidth, char *str,
339 fmtwidth -= width; 339 fmtwidth -= width;
340 mach->ind += fmtwidth; 340 mach->ind += fmtwidth;
341 while (fmtwidth--) 341 while (fmtwidth--)
342 obstack_1grow (&mach->stk, ' '); 342 mu_opool_append_char (mach->pool, ' ');
343 } 343 }
344 } 344 }
345 345
...@@ -394,7 +394,7 @@ format_num (struct mh_machine *mach, long num) ...@@ -394,7 +394,7 @@ format_num (struct mh_machine *mach, long num)
394 ptr = buf; 394 ptr = buf;
395 for (i = n; i < fmtwidth && mach->ind < mach->width; 395 for (i = n; i < fmtwidth && mach->ind < mach->width;
396 i++, mach->ind++) 396 i++, mach->ind++)
397 obstack_1grow (&mach->stk, padchar); 397 mu_opool_append_char (mach->pool, padchar);
398 } 398 }
399 } 399 }
400 else 400 else
...@@ -422,7 +422,7 @@ format_str (struct mh_machine *mach, char *str) ...@@ -422,7 +422,7 @@ format_str (struct mh_machine *mach, char *str)
422 n = fmtwidth - len; 422 n = fmtwidth - len;
423 for (i = 0; i < n && mach->ind < mach->width; 423 for (i = 0; i < n && mach->ind < mach->width;
424 i++, mach->ind++, fmtwidth--) 424 i++, mach->ind++, fmtwidth--)
425 obstack_1grow (&mach->stk, padchar); 425 mu_opool_append_char (mach->pool, padchar);
426 } 426 }
427 427
428 print_fmt_string (mach, fmtwidth, str); 428 print_fmt_string (mach, fmtwidth, str);
...@@ -491,7 +491,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno, ...@@ -491,7 +491,7 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
491 491
492 mach.width = width - 1; /* Count the newline */ 492 mach.width = width - 1; /* Count the newline */
493 mach.pc = 1; 493 mach.pc = 1;
494 obstack_init (&mach.stk); 494 mu_opool_create (&mach.pool, 1);
495 mu_list_create (&mach.addrlist); 495 mu_list_create (&mach.addrlist);
496 496
497 reset_fmt_defaults (&mach); 497 reset_fmt_defaults (&mach);
...@@ -678,10 +678,10 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno, ...@@ -678,10 +678,10 @@ mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
678 678
679 if (pret) 679 if (pret)
680 { 680 {
681 obstack_1grow (&mach.stk, 0); 681 mu_opool_append_char (mach.pool, 0);
682 *pret = mu_strdup (obstack_finish (&mach.stk)); 682 *pret = mu_strdup (mu_opool_finish (mach.pool, NULL));
683 } 683 }
684 obstack_free (&mach.stk, NULL); 684 mu_opool_destroy (&mach.pool);
685 return mach.ind; 685 return mach.ind;
686 } 686 }
687 687
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ 15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16 16
17 #define obstack_chunk_alloc malloc
18 #define obstack_chunk_free free
19 #include <obstack.h>
20
21 typedef struct /* A string object type */ 17 typedef struct /* A string object type */
22 { 18 {
23 int size; /* Allocated size or 0 for static storage */ 19 int size; /* Allocated size or 0 for static storage */
...@@ -43,7 +39,7 @@ struct mh_machine ...@@ -43,7 +39,7 @@ struct mh_machine
43 mh_instr_t *prog; /* Program itself */ 39 mh_instr_t *prog; /* Program itself */
44 int stop; /* Stop execution immediately */ 40 int stop; /* Stop execution immediately */
45 41
46 struct obstack stk; /* Output buffer */ 42 mu_opool_t pool; /* Output buffer */
47 size_t width; /* Output buffer width */ 43 size_t width; /* Output buffer width */
48 size_t ind; /* Output buffer index */ 44 size_t ind; /* Output buffer index */
49 45
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
19 #include <mh.h> 19 #include <mh.h>
20 #include <signal.h> 20 #include <signal.h>
21 #include <mailutils/mime.h> 21 #include <mailutils/mime.h>
22 #define obstack_chunk_alloc mu_alloc
23 #define obstack_chunk_free free
24 #include <obstack.h>
25 #include <setjmp.h> 22 #include <setjmp.h>
26 23
27 static char doc[] = N_("GNU MH mhn")"\v" 24 static char doc[] = N_("GNU MH mhn")"\v"
...@@ -541,7 +538,7 @@ msg_part_format (msg_part_t p) ...@@ -541,7 +538,7 @@ msg_part_format (msg_part_t p)
541 } 538 }
542 539
543 void 540 void
544 msg_part_format_stk (struct obstack *stk, msg_part_t p) 541 msg_part_format_pool (mu_opool_t pool, msg_part_t p)
545 { 542 {
546 int i; 543 int i;
547 544
...@@ -551,11 +548,11 @@ msg_part_format_stk (struct obstack *stk, msg_part_t p) ...@@ -551,11 +548,11 @@ msg_part_format_stk (struct obstack *stk, msg_part_t p)
551 const char *buf; 548 const char *buf;
552 549
553 if (i > 1) 550 if (i > 1)
554 obstack_1grow (stk, '.'); 551 mu_opool_append_char (pool, '.');
555 552
556 buf = mu_umaxtostr (0, p->part[i]); 553 buf = mu_umaxtostr (0, p->part[i]);
557 len = strlen (buf); 554 len = strlen (buf);
558 obstack_grow (stk, buf, len); 555 mu_opool_append (pool, buf, len);
559 } 556 }
560 } 557 }
561 558
...@@ -634,7 +631,7 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file) ...@@ -634,7 +631,7 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file)
634 const char *p, *str; 631 const char *p, *str;
635 char *type, *subtype, **typeargv = NULL; 632 char *type, *subtype, **typeargv = NULL;
636 int typeargc = 0; 633 int typeargc = 0;
637 struct obstack stk; 634 mu_opool_t pool;
638 635
639 split_content (typestr, &type, &subtype); 636 split_content (typestr, &type, &subtype);
640 str = _mhn_profile_get ("compose", type, subtype, NULL); 637 str = _mhn_profile_get ("compose", type, subtype, NULL);
...@@ -647,7 +644,8 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file) ...@@ -647,7 +644,8 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file)
647 %F %f, and stdout is not redirected 644 %F %f, and stdout is not redirected
648 %s subtype */ 645 %s subtype */
649 646
650 obstack_init (&stk); 647 mu_opool_create (&pool, 1);
648
651 p = mu_str_skip_class (str, MU_CTYPE_SPACE); 649 p = mu_str_skip_class (str, MU_CTYPE_SPACE);
652 650
653 if (*p == '|') 651 if (*p == '|')
...@@ -671,8 +669,8 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file) ...@@ -671,8 +669,8 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file)
671 for (i = 0; i < typeargc; i++) 669 for (i = 0; i < typeargc; i++)
672 { 670 {
673 if (i > 0) 671 if (i > 0)
674 obstack_1grow (&stk, ' '); 672 mu_opool_append_char (pool, ' ');
675 obstack_grow (&stk, typeargv[i], strlen (typeargv[i])); 673 mu_opool_appendz (pool, typeargv[i]);
676 } 674 }
677 } 675 }
678 break; 676 break;
...@@ -682,36 +680,36 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file) ...@@ -682,36 +680,36 @@ mhn_compose_command (char *typestr, char *typeargs, int *flags, char *file)
682 *flags |= MHN_STDIN; 680 *flags |= MHN_STDIN;
683 /*FALLTHRU*/ 681 /*FALLTHRU*/
684 case 'f': 682 case 'f':
685 obstack_grow (&stk, file, strlen (file)); 683 mu_opool_appendz (pool, file);
686 break; 684 break;
687 685
688 case 's': 686 case 's':
689 /* subtype */ 687 /* subtype */
690 obstack_grow (&stk, subtype, strlen (subtype)); 688 mu_opool_appendz (pool, subtype);
691 break; 689 break;
692 690
693 default: 691 default:
694 obstack_1grow (&stk, *p); 692 mu_opool_append_char (pool, *p);
695 p++; 693 p++;
696 } 694 }
697 } 695 }
698 else 696 else
699 obstack_1grow (&stk, *p); 697 mu_opool_append_char (pool, *p);
700 } 698 }
701 obstack_1grow (&stk, 0); 699 mu_opool_append_char (pool, 0);
702 700
703 free (type); 701 free (type);
704 free (subtype); 702 free (subtype);
705 mu_argcv_free (typeargc, typeargv); 703 mu_argcv_free (typeargc, typeargv);
706 704
707 str = obstack_finish (&stk); 705 str = mu_opool_finish (pool, NULL);
708 p = mu_str_skip_class (str, MU_CTYPE_SPACE); 706 p = mu_str_skip_class (str, MU_CTYPE_SPACE);
709 if (!*p) 707 if (!*p)
710 str = NULL; 708 str = NULL;
711 else 709 else
712 str = mu_strdup (p); 710 str = mu_strdup (p);
713 711
714 obstack_free (&stk, NULL); 712 mu_opool_destroy (&pool);
715 return (char*) str; 713 return (char*) str;
716 } 714 }
717 715
...@@ -767,7 +765,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -767,7 +765,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
767 { 765 {
768 const char *p, *str, *tmp; 766 const char *p, *str, *tmp;
769 char *typestr, *type, *subtype, *typeargs; 767 char *typestr, *type, *subtype, *typeargs;
770 struct obstack stk; 768 mu_opool_t pool;
771 mu_header_t hdr; 769 mu_header_t hdr;
772 char *temp_cmd = NULL; 770 char *temp_cmd = NULL;
773 int typeargc = 0; 771 int typeargc = 0;
...@@ -827,7 +825,8 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -827,7 +825,8 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
827 %s subtype 825 %s subtype
828 %d content description */ 826 %d content description */
829 827
830 obstack_init (&stk); 828 mu_opool_create (&pool, 1);
829
831 p = mu_str_skip_class (str, MU_CTYPE_SPACE); 830 p = mu_str_skip_class (str, MU_CTYPE_SPACE);
832 831
833 if (*p == '|') 832 if (*p == '|')
...@@ -851,8 +850,8 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -851,8 +850,8 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
851 for (i = 0; i < typeargc; i++) 850 for (i = 0; i < typeargc; i++)
852 { 851 {
853 if (i > 0) 852 if (i > 0)
854 obstack_1grow (&stk, ' '); 853 mu_opool_append_char (pool, ' ');
855 obstack_grow (&stk, typeargv[i], strlen (typeargv[i])); 854 mu_opool_appendz (pool, typeargv[i]);
856 } 855 }
857 } 856 }
858 break; 857 break;
...@@ -866,7 +865,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -866,7 +865,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
866 /* filename containing content */ 865 /* filename containing content */
867 if (!*tempfile) 866 if (!*tempfile)
868 mhn_tempfile_name (tempfile, type, subtype); 867 mhn_tempfile_name (tempfile, type, subtype);
869 obstack_grow (&stk, *tempfile, strlen (*tempfile)); 868 mu_opool_appendz (pool, *tempfile);
870 break; 869 break;
871 870
872 case 'F': 871 case 'F':
...@@ -874,7 +873,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -874,7 +873,7 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
874 *flags |= MHN_STDIN|MHN_EXCLUSIVE_EXEC; 873 *flags |= MHN_STDIN|MHN_EXCLUSIVE_EXEC;
875 if (!*tempfile) 874 if (!*tempfile)
876 mhn_tempfile_name (tempfile, type, subtype); 875 mhn_tempfile_name (tempfile, type, subtype);
877 obstack_grow (&stk, *tempfile, strlen (*tempfile)); 876 mu_opool_appendz (pool, *tempfile);
878 break; 877 break;
879 878
880 case 'l': 879 case 'l':
...@@ -889,25 +888,25 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -889,25 +888,25 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
889 888
890 case 's': 889 case 's':
891 /* subtype */ 890 /* subtype */
892 obstack_grow (&stk, subtype, strlen (subtype)); 891 mu_opool_appendz (pool, subtype);
893 break; 892 break;
894 893
895 case 'd': 894 case 'd':
896 /* content description */ 895 /* content description */
897 if (mu_header_sget_value (hdr, MU_HEADER_CONTENT_DESCRIPTION, 896 if (mu_header_sget_value (hdr, MU_HEADER_CONTENT_DESCRIPTION,
898 &tmp) == 0) 897 &tmp) == 0)
899 obstack_grow (&stk, tmp, strlen (tmp)); 898 mu_opool_appendz (pool, tmp);
900 break; 899 break;
901 900
902 default: 901 default:
903 obstack_1grow (&stk, *p); 902 mu_opool_append_char (pool, *p);
904 p++; 903 p++;
905 } 904 }
906 } 905 }
907 else 906 else
908 obstack_1grow (&stk, *p); 907 mu_opool_append_char (pool, *p);
909 } 908 }
910 obstack_1grow (&stk, 0); 909 mu_opool_append_char (pool, 0);
911 910
912 free (typestr); 911 free (typestr);
913 free (type); 912 free (type);
...@@ -915,14 +914,14 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, ...@@ -915,14 +914,14 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
915 free (temp_cmd); 914 free (temp_cmd);
916 mu_argcv_free (typeargc, typeargv); 915 mu_argcv_free (typeargc, typeargv);
917 916
918 str = obstack_finish (&stk); 917 str = mu_opool_finish (pool, NULL);
919 p = mu_str_skip_class (str, MU_CTYPE_SPACE); 918 p = mu_str_skip_class (str, MU_CTYPE_SPACE);
920 if (!*p) 919 if (!*p)
921 str = NULL; 920 str = NULL;
922 else 921 else
923 str = mu_strdup (p); 922 str = mu_strdup (p);
924 923
925 obstack_free (&stk, NULL); 924 mu_opool_destroy (&pool);
926 return (char*) str; 925 return (char*) str;
927 } 926 }
928 927
...@@ -941,7 +940,7 @@ mhn_store_command (mu_message_t msg, msg_part_t part, const char *name, ...@@ -941,7 +940,7 @@ mhn_store_command (mu_message_t msg, msg_part_t part, const char *name,
941 { 940 {
942 const char *p, *str, *tmp; 941 const char *p, *str, *tmp;
943 char *typestr, *type, *subtype, *typeargs; 942 char *typestr, *type, *subtype, *typeargs;
944 struct obstack stk; 943 mu_opool_t pool;
945 mu_header_t hdr; 944 mu_header_t hdr;
946 enum store_destination dest; 945 enum store_destination dest;
947 946
...@@ -998,7 +997,8 @@ mhn_store_command (mu_message_t msg, msg_part_t part, const char *name, ...@@ -998,7 +997,8 @@ mhn_store_command (mu_message_t msg, msg_part_t part, const char *name,
998 %p part 997 %p part
999 %s subtype */ 998 %s subtype */
1000 999
1001 obstack_init (&stk); 1000 mu_opool_create (&pool, 1);
1001
1002 for (p = str; *p; p++) 1002 for (p = str; *p; p++)
1003 { 1003 {
1004 if (*p == '%') 1004 if (*p == '%')
...@@ -1007,62 +1007,62 @@ mhn_store_command (mu_message_t msg, msg_part_t part, const char *name, ...@@ -1007,62 +1007,62 @@ mhn_store_command (mu_message_t msg, msg_part_t part, const char *name,
1007 { 1007 {
1008 case 'a': 1008 case 'a':
1009 /* additional arguments */ 1009 /* additional arguments */
1010 obstack_grow (&stk, typeargs, strlen (typeargs)); 1010 mu_opool_appendz (pool, typeargs);
1011 break; 1011 break;
1012 1012
1013 case 'm': 1013 case 'm':
1014 if (name) 1014 if (name)
1015 obstack_grow (&stk, name, strlen (name)); 1015 mu_opool_appendz (pool, name);
1016 else 1016 else
1017 { 1017 {
1018 const char *buf = mu_umaxtostr (0, msg_part_subpart (part, 0)); 1018 const char *buf = mu_umaxtostr (0, msg_part_subpart (part, 0));
1019 obstack_grow (&stk, buf, strlen (buf)); 1019 mu_opool_appendz (pool, buf);
1020 } 1020 }
1021 break; 1021 break;
1022 1022
1023 case 'P': 1023 case 'P':
1024 if (msg_part_level (part) >= 1) 1024 if (msg_part_level (part) >= 1)
1025 obstack_1grow (&stk, '.'); 1025 mu_opool_append_char (pool, '.');
1026 /*FALLTHRU*/ 1026 /*FALLTHRU*/
1027 case 'p': 1027 case 'p':
1028 if (msg_part_level (part) >= 1) 1028 if (msg_part_level (part) >= 1)
1029 msg_part_format_stk (&stk, part); 1029 msg_part_format_pool (pool, part);
1030 break; 1030 break;
1031 1031
1032 case 's': 1032 case 's':
1033 /* subtype */ 1033 /* subtype */
1034 obstack_grow (&stk, subtype, strlen (subtype)); 1034 mu_opool_appendz (pool, subtype);
1035 break; 1035 break;
1036 1036
1037 case 'd': 1037 case 'd':
1038 /* content description */ 1038 /* content description */
1039 if (mu_header_sget_value (hdr, MU_HEADER_CONTENT_DESCRIPTION, 1039 if (mu_header_sget_value (hdr, MU_HEADER_CONTENT_DESCRIPTION,
1040 &tmp) == 0) 1040 &tmp) == 0)
1041 obstack_grow (&stk, tmp, strlen (tmp)); 1041 mu_opool_appendz (pool, tmp);
1042 break; 1042 break;
1043 1043
1044 default: 1044 default:
1045 obstack_1grow (&stk, *p); 1045 mu_opool_append_char (pool, *p);
1046 p++; 1046 p++;
1047 } 1047 }
1048 } 1048 }
1049 else 1049 else
1050 obstack_1grow (&stk, *p); 1050 mu_opool_append_char (pool, *p);
1051 } 1051 }
1052 obstack_1grow (&stk, *p); 1052 mu_opool_append_char (pool, *p);
1053 1053
1054 free (typestr); 1054 free (typestr);
1055 free (type); 1055 free (type);
1056 free (subtype); 1056 free (subtype);
1057 1057
1058 str = obstack_finish (&stk); 1058 str = mu_opool_finish (pool, NULL);
1059 p = mu_str_skip_class (str, MU_CTYPE_SPACE); 1059 p = mu_str_skip_class (str, MU_CTYPE_SPACE);
1060 if (!*p) 1060 if (!*p)
1061 *return_string = NULL; 1061 *return_string = NULL;
1062 else 1062 else
1063 *return_string = mu_strdup (p); 1063 *return_string = mu_strdup (p);
1064 1064
1065 obstack_free (&stk, NULL); 1065 mu_opool_destroy (&pool);
1066 return dest; 1066 return dest;
1067 } 1067 }
1068 1068
...@@ -1932,7 +1932,7 @@ parse_brace (char **pval, char **cmd, int c, struct compose_env *env) ...@@ -1932,7 +1932,7 @@ parse_brace (char **pval, char **cmd, int c, struct compose_env *env)
1932 1932
1933 int 1933 int
1934 parse_content_type (struct compose_env *env, 1934 parse_content_type (struct compose_env *env,
1935 struct obstack *stk, char **prest, char **id, char **descr) 1935 mu_opool_t pool, char **prest, char **id, char **descr)
1936 { 1936 {
1937 int status = 0, stop = 0; 1937 int status = 0, stop = 0;
1938 char *rest = *prest; 1938 char *rest = *prest;
...@@ -1990,12 +1990,12 @@ parse_content_type (struct compose_env *env, ...@@ -1990,12 +1990,12 @@ parse_content_type (struct compose_env *env,
1990 break; 1990 break;
1991 1991
1992 case ';': 1992 case ';':
1993 obstack_1grow (stk, ';'); 1993 mu_opool_append_char (pool, ';');
1994 obstack_1grow (stk, ' '); 1994 mu_opool_append_char (pool, ' ');
1995 skipws (rest); 1995 skipws (rest);
1996 sp = rest; 1996 sp = rest;
1997 for (; *rest && !mu_isspace (*rest) && *rest != '='; rest++) 1997 for (; *rest && !mu_isspace (*rest) && *rest != '='; rest++)
1998 obstack_1grow (stk, *rest); 1998 mu_opool_append_char (pool, *rest);
1999 skipws (rest); 1999 skipws (rest);
2000 if (*rest != '=') 2000 if (*rest != '=')
2001 { 2001 {
...@@ -2006,13 +2006,13 @@ parse_content_type (struct compose_env *env, ...@@ -2006,13 +2006,13 @@ parse_content_type (struct compose_env *env,
2006 break; 2006 break;
2007 } 2007 }
2008 rest++; 2008 rest++;
2009 obstack_1grow (stk, '='); 2009 mu_opool_append_char (pool, '=');
2010 skipws (rest); 2010 skipws (rest);
2011 for (; *rest; rest++) 2011 for (; *rest; rest++)
2012 { 2012 {
2013 if (isdelim (*rest)) 2013 if (isdelim (*rest))
2014 break; 2014 break;
2015 obstack_1grow (stk, *rest); 2015 mu_opool_append_char (pool, *rest);
2016 } 2016 }
2017 break; 2017 break;
2018 2018
...@@ -2025,9 +2025,9 @@ parse_content_type (struct compose_env *env, ...@@ -2025,9 +2025,9 @@ parse_content_type (struct compose_env *env,
2025 2025
2026 if (comment) 2026 if (comment)
2027 { 2027 {
2028 obstack_grow (stk, " (", 2); 2028 mu_opool_append (pool, " (", 2);
2029 obstack_grow (stk, comment, strlen (comment)); 2029 mu_opool_appendz (pool, comment);
2030 obstack_1grow (stk, ')'); 2030 mu_opool_append_char (pool, ')');
2031 free (comment); 2031 free (comment);
2032 } 2032 }
2033 *prest = rest; 2033 *prest = rest;
...@@ -2048,7 +2048,7 @@ parse_type_command (char **pcmd, struct compose_env *env, mu_header_t hdr) ...@@ -2048,7 +2048,7 @@ parse_type_command (char **pcmd, struct compose_env *env, mu_header_t hdr)
2048 char *type = NULL; 2048 char *type = NULL;
2049 char *subtype = NULL; 2049 char *subtype = NULL;
2050 char *descr = NULL, *id = NULL; 2050 char *descr = NULL, *id = NULL;
2051 struct obstack stk; 2051 mu_opool_t pool;
2052 char *rest = *pcmd; 2052 char *rest = *pcmd;
2053 2053
2054 skipws (rest); 2054 skipws (rest);
...@@ -2068,15 +2068,17 @@ parse_type_command (char **pcmd, struct compose_env *env, mu_header_t hdr) ...@@ -2068,15 +2068,17 @@ parse_type_command (char **pcmd, struct compose_env *env, mu_header_t hdr)
2068 return 1; 2068 return 1;
2069 } 2069 }
2070 2070
2071 obstack_init (&stk); 2071 mu_opool_create (&pool, 1);
2072 obstack_grow (&stk, type, strlen (type)); 2072
2073 obstack_1grow (&stk, '/'); 2073 mu_opool_appendz (pool, type);
2074 obstack_grow (&stk, subtype, strlen (subtype)); 2074 mu_opool_append_char (pool, '/');
2075 status = parse_content_type (env, &stk, &rest, &id, &descr); 2075 mu_opool_appendz (pool, subtype);
2076 obstack_1grow (&stk, 0); 2076 status = parse_content_type (env, pool, &rest, &id, &descr);
2077 mu_opool_append_char (pool, 0);
2077 2078
2078 mu_header_set_value (hdr, MU_HEADER_CONTENT_TYPE, obstack_finish (&stk), 1); 2079 mu_header_set_value (hdr, MU_HEADER_CONTENT_TYPE,
2079 obstack_free (&stk, NULL); 2080 mu_opool_finish (pool, NULL), 1);
2081 mu_opool_destroy (&pool);
2080 2082
2081 if (!id) 2083 if (!id)
2082 id = mh_create_message_id (env->subpart); 2084 id = mh_create_message_id (env->subpart);
...@@ -2217,7 +2219,7 @@ edit_extern (char *cmd, struct compose_env *env, mu_message_t *msg, int level) ...@@ -2217,7 +2219,7 @@ edit_extern (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
2217 mu_header_t hdr, hdr2; 2219 mu_header_t hdr, hdr2;
2218 mu_body_t body; 2220 mu_body_t body;
2219 mu_stream_t in, out = NULL; 2221 mu_stream_t in, out = NULL;
2220 struct obstack stk; 2222 mu_opool_t pool;
2221 2223
2222 if (!*msg) 2224 if (!*msg)
2223 mu_message_create (msg, NULL); 2225 mu_message_create (msg, NULL);
...@@ -2234,13 +2236,14 @@ edit_extern (char *cmd, struct compose_env *env, mu_message_t *msg, int level) ...@@ -2234,13 +2236,14 @@ edit_extern (char *cmd, struct compose_env *env, mu_message_t *msg, int level)
2234 2236
2235 mu_message_get_header (*msg, &hdr); 2237 mu_message_get_header (*msg, &hdr);
2236 2238
2237 obstack_init (&stk); 2239 mu_opool_create (&pool, 1);
2238 obstack_grow (&stk, EXTCONTENT, sizeof (EXTCONTENT) - 1); 2240 mu_opool_append (pool, EXTCONTENT, sizeof (EXTCONTENT) - 1);
2239 *--rest = ';'; /* FIXME */ 2241 *--rest = ';'; /* FIXME */
2240 rc = parse_content_type (env, &stk, &rest, &id, NULL); 2242 rc = parse_content_type (env, pool, &rest, &id, NULL);
2241 obstack_1grow (&stk, 0); 2243 mu_opool_append_char (pool, 0);
2242 mu_header_set_value (hdr, MU_HEADER_CONTENT_TYPE, obstack_finish (&stk), 1); 2244 mu_header_set_value (hdr, MU_HEADER_CONTENT_TYPE,
2243 obstack_free (&stk, NULL); 2245 mu_opool_finish (pool, NULL), 1);
2246 mu_opool_destroy (&pool);
2244 if (rc) 2247 if (rc)
2245 return 1; 2248 return 1;
2246 2249
......
...@@ -120,7 +120,7 @@ static char *mhl_filter = NULL; /* --filter flag */ ...@@ -120,7 +120,7 @@ static char *mhl_filter = NULL; /* --filter flag */
120 static int annotate; /* --annotate flag */ 120 static int annotate; /* --annotate flag */
121 static char *draftmessage = "new"; 121 static char *draftmessage = "new";
122 static const char *draftfolder = NULL; 122 static const char *draftfolder = NULL;
123 static struct obstack fcc_stack; 123 static mu_opool_t fcc_pool;
124 static int has_fcc; 124 static int has_fcc;
125 125
126 static int 126 static int
...@@ -243,12 +243,12 @@ opt_handler (int key, char *arg, struct argp_state *state) ...@@ -243,12 +243,12 @@ opt_handler (int key, char *arg, struct argp_state *state)
243 case ARG_FCC: 243 case ARG_FCC:
244 if (!has_fcc) 244 if (!has_fcc)
245 { 245 {
246 obstack_init (&fcc_stack); 246 mu_opool_create (&fcc_pool, 1);
247 has_fcc = 1; 247 has_fcc = 1;
248 } 248 }
249 else 249 else
250 obstack_grow (&fcc_stack, ", ", 2); 250 mu_opool_append (fcc_pool, ", ", 2);
251 obstack_grow (&fcc_stack, arg, strlen (arg)); 251 mu_opool_appendz (fcc_pool, arg);
252 break; 252 break;
253 253
254 case ARG_INPLACE: 254 case ARG_INPLACE:
...@@ -348,7 +348,7 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh) ...@@ -348,7 +348,7 @@ make_draft (mu_mailbox_t mbox, int disp, struct mh_whatnow_env *wh)
348 348
349 mu_message_create_copy (&tmp_msg, msg); 349 mu_message_create_copy (&tmp_msg, msg);
350 mu_message_get_header (tmp_msg, &hdr); 350 mu_message_get_header (tmp_msg, &hdr);
351 text = obstack_finish (&fcc_stack); 351 text = mu_opool_finish (fcc_pool, NULL);
352 mu_header_set_value (hdr, MU_HEADER_FCC, text, 0); 352 mu_header_set_value (hdr, MU_HEADER_FCC, text, 0);
353 mh_format (&format, tmp_msg, msgno, width, &buf); 353 mh_format (&format, tmp_msg, msgno, width, &buf);
354 mu_message_destroy (&tmp_msg, NULL); 354 mu_message_destroy (&tmp_msg, NULL);
......
...@@ -97,7 +97,7 @@ mh_whatnow_env_to_environ (struct mh_whatnow_env *wh) ...@@ -97,7 +97,7 @@ mh_whatnow_env_to_environ (struct mh_whatnow_env *wh)
97 if (prev_uid == 0) 97 if (prev_uid == 0)
98 { 98 {
99 s = mu_umaxtostr (0, uid); 99 s = mu_umaxtostr (0, uid);
100 mu_opool_append (opool, s, strlen (s)); 100 mu_opool_appendz (opool, s);
101 mrange = 0; 101 mrange = 0;
102 } 102 }
103 else if (uid == prev_uid + 1) 103 else if (uid == prev_uid + 1)
...@@ -108,11 +108,11 @@ mh_whatnow_env_to_environ (struct mh_whatnow_env *wh) ...@@ -108,11 +108,11 @@ mh_whatnow_env_to_environ (struct mh_whatnow_env *wh)
108 { 108 {
109 mu_opool_append_char (opool, '-'); 109 mu_opool_append_char (opool, '-');
110 s = mu_umaxtostr (0, prev_uid); 110 s = mu_umaxtostr (0, prev_uid);
111 mu_opool_append (opool, s, strlen (s)); 111 mu_opool_appendz (opool, s);
112 } 112 }
113 mu_opool_append_char (opool, ' '); 113 mu_opool_append_char (opool, ' ');
114 s = mu_umaxtostr (0, uid); 114 s = mu_umaxtostr (0, uid);
115 mu_opool_append (opool, s, strlen (s)); 115 mu_opool_appendz (opool, s);
116 mrange = 0; 116 mrange = 0;
117 } 117 }
118 } 118 }
...@@ -121,7 +121,7 @@ mh_whatnow_env_to_environ (struct mh_whatnow_env *wh) ...@@ -121,7 +121,7 @@ mh_whatnow_env_to_environ (struct mh_whatnow_env *wh)
121 { 121 {
122 mu_opool_append_char (opool, '-'); 122 mu_opool_append_char (opool, '-');
123 s = mu_umaxtostr (0, prev_uid); 123 s = mu_umaxtostr (0, prev_uid);
124 mu_opool_append (opool, s, strlen (s)); 124 mu_opool_appendz (opool, s);
125 } 125 }
126 mu_opool_append_char (opool, 0); 126 mu_opool_append_char (opool, 0);
127 s = mu_opool_finish (opool, NULL); 127 s = mu_opool_finish (opool, NULL);
......
...@@ -32,7 +32,7 @@ static int line_num; ...@@ -32,7 +32,7 @@ static int line_num;
32 static char *file_name; 32 static char *file_name;
33 static int file_name_alloc; 33 static int file_name_alloc;
34 34
35 static struct obstack stack; 35 static mu_opool_t pool;
36 static int prev_state; 36 static int prev_state;
37 37
38 static unsigned 38 static unsigned
...@@ -56,25 +56,22 @@ WS [ \t]* ...@@ -56,25 +56,22 @@ WS [ \t]*
56 \n { line_num++; return EOL; } 56 \n { line_num++; return EOL; }
57 {WS} ; 57 {WS} ;
58 {IDENT} { 58 {IDENT} {
59 obstack_grow (&stack, yytext, yyleng); 59 mu_opool_append (pool, yytext, yyleng);
60 yylval.string.len = obstack_object_size (&stack); 60 mu_opool_append_char (pool, 0);
61 obstack_1grow (&stack, 0); 61 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
62 yylval.string.ptr = obstack_finish (&stack);
63 return IDENT; 62 return IDENT;
64 } 63 }
65 <INITIAL>{IDENT}"(" { 64 <INITIAL>{IDENT}"(" {
66 obstack_grow (&stack, yytext, yyleng-1); 65 mu_opool_append (pool, yytext, yyleng-1);
67 yylval.string.len = obstack_object_size (&stack); 66 mu_opool_append_char (pool, 0);
68 obstack_1grow (&stack, 0); 67 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
69 yylval.string.ptr = obstack_finish (&stack);
70 BEGIN(ARGS); 68 BEGIN(ARGS);
71 return IDENT_L; 69 return IDENT_L;
72 } 70 }
73 <INITIAL,ARGS>\"[^\\"\n]*\" { 71 <INITIAL,ARGS>\"[^\\"\n]*\" {
74 obstack_grow (&stack, yytext+1, yyleng-2); 72 mu_opool_append (pool, yytext+1, yyleng-2);
75 yylval.string.len = obstack_object_size (&stack); 73 mu_opool_append_char (pool, 0);
76 obstack_1grow (&stack, 0); 74 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
77 yylval.string.ptr = obstack_finish (&stack);
78 return STRING; 75 return STRING;
79 } 76 }
80 <INITIAL,ARGS>"<" { 77 <INITIAL,ARGS>"<" {
...@@ -82,40 +79,36 @@ WS [ \t]* ...@@ -82,40 +79,36 @@ WS [ \t]*
82 BEGIN(HEX); 79 BEGIN(HEX);
83 } 80 }
84 <ARGS>[^ \t<\\\n),]+/[),] { 81 <ARGS>[^ \t<\\\n),]+/[),] {
85 obstack_grow (&stack, yytext, yyleng); 82 mu_opool_append (pool, yytext, yyleng);
86 yylval.string.len = obstack_object_size (&stack); 83 mu_opool_append_char (pool, 0);
87 obstack_1grow (&stack, 0); 84 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
88 yylval.string.ptr = obstack_finish (&stack);
89 return STRING; 85 return STRING;
90 } 86 }
91 <ARGS>[^ \t<\\\n),]+< { 87 <ARGS>[^ \t<\\\n),]+< {
92 obstack_grow (&stack, yytext, yyleng); 88 mu_opool_append (pool, yytext, yyleng);
93 prev_state = YYSTATE; 89 prev_state = YYSTATE;
94 BEGIN(HEX); 90 BEGIN(HEX);
95 } 91 }
96 <INITIAL>[^ \t<\\\n)+,&]/[ \t\\\n)+,&] { 92 <INITIAL>[^ \t<\\\n)+,&]/[ \t\\\n)+,&] {
97 obstack_grow (&stack, yytext, yyleng); 93 mu_opool_append (pool, yytext, yyleng);
98 yylval.string.len = obstack_object_size (&stack); 94 mu_opool_append_char (pool, 0);
99 obstack_1grow (&stack, 0); 95 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
100 yylval.string.ptr = obstack_finish (&stack);
101 return STRING; 96 return STRING;
102 } 97 }
103 <ARGS>[^ \t<\\\n),]/[ \t\\\n] { 98 <ARGS>[^ \t<\\\n),]/[ \t\\\n] {
104 obstack_grow (&stack, yytext, yyleng); 99 mu_opool_append (pool, yytext, yyleng);
105 yylval.string.len = obstack_object_size (&stack); 100 mu_opool_append_char (pool, 0);
106 obstack_1grow (&stack, 0); 101 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
107 yylval.string.ptr = obstack_finish (&stack);
108 return STRING; 102 return STRING;
109 } 103 }
110 <HEX>{X}{X} { 104 <HEX>{X}{X} {
111 int c = digit_to_number (yytext[0])*16 + digit_to_number (yytext[1]); 105 int c = digit_to_number (yytext[0])*16 + digit_to_number (yytext[1]);
112 obstack_1grow (&stack, c); 106 mu_opool_append_char (pool, c);
113 } 107 }
114 <HEX>">"/[ \t\\\n,)] { 108 <HEX>">"/[ \t\\\n,)] {
115 BEGIN(prev_state); 109 BEGIN(prev_state);
116 yylval.string.len = obstack_object_size (&stack); 110 mu_opool_append_char (pool, 0);
117 obstack_1grow (&stack, 0); 111 yylval.string.ptr = mu_opool_finish (pool, &yylval.string.len);
118 yylval.string.ptr = obstack_finish (&stack);
119 return STRING; 112 return STRING;
120 } 113 }
121 <HEX>">" { 114 <HEX>">" {
...@@ -174,7 +167,7 @@ mimetypes_open (const char *name) ...@@ -174,7 +167,7 @@ mimetypes_open (const char *name)
174 return -1; 167 return -1;
175 } 168 }
176 line_num = 1; 169 line_num = 1;
177 obstack_init (&stack); 170 mu_opool_create (&pool, 1);
178 return 0; 171 return 0;
179 } 172 }
180 173
...@@ -210,25 +203,26 @@ mimetypes_append_string2 (struct mimetypes_string *s1, ...@@ -210,25 +203,26 @@ mimetypes_append_string2 (struct mimetypes_string *s1,
210 struct mimetypes_string r; 203 struct mimetypes_string r;
211 204
212 r.len = s1->len + s2->len + 1; 205 r.len = s1->len + s2->len + 1;
213 obstack_grow (&stack, s1->ptr, s1->len); 206 mu_opool_append (pool, s1->ptr, s1->len);
214 obstack_1grow (&stack, c); 207 mu_opool_append_char (pool, c);
215 obstack_grow (&stack, s2->ptr, s2->len); 208 mu_opool_append (pool, s2->ptr, s2->len);
216 obstack_1grow (&stack, 0); 209 mu_opool_append_char (pool, 0);
217 r.ptr = obstack_finish (&stack); 210 r.ptr = mu_opool_finish (pool, NULL);
218 return r; 211 return r;
219 } 212 }
220 213
221 struct mimetypes_string * 214 struct mimetypes_string *
222 mimetypes_string_dup (struct mimetypes_string *s) 215 mimetypes_string_dup (struct mimetypes_string *s)
223 { 216 {
224 obstack_grow (&stack, s, sizeof *s); 217 mu_opool_append (pool, s, sizeof *s);
225 return obstack_finish (&stack); 218 return mu_opool_finish (pool, NULL);
226 } 219 }
227 220
228 void * 221 void *
229 mimetypes_malloc (size_t size) 222 mimetypes_malloc (size_t size)
230 { 223 {
231 return obstack_alloc(&stack, size); 224 mu_opool_alloc (pool, size);
225 return mu_opool_finish (pool, NULL);
232 } 226 }
233 227
234 void 228 void
......
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
22 #endif 22 #endif
23 #include <mailutils/mailutils.h> 23 #include <mailutils/mailutils.h>
24 #include <fnmatch.h> 24 #include <fnmatch.h>
25 #define obstack_chunk_alloc malloc
26 #define obstack_chunk_free free
27 #include <obstack.h>
28 25
29 struct mimetypes_string 26 struct mimetypes_string
30 { 27 {
......