0
|
1 /*
|
|
2 * $Id: rk_alloc.c,v 1.2 2001/06/14 18:16:09 ura Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 *
|
|
14 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
|
|
15 *
|
|
16 * This program is free software; you can redistribute it and/or modify
|
|
17 * it under the terms of the GNU General Public License as published by
|
|
18 * the Free Software Foundation; either version 2, or (at your option)
|
|
19 * any later version.
|
|
20 *
|
|
21 * This program is distributed in the hope that it will be useful,
|
|
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24 * GNU General Public License for more details.
|
|
25 *
|
|
26 * You should have received a copy of the GNU General Public License
|
|
27 * along with GNU Emacs; see the file COPYING. If not, write to the
|
|
28 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
29 *
|
|
30 * Commentary:
|
|
31 *
|
|
32 * Change log:
|
|
33 *
|
|
34 * Last modified date: 8,Feb.1999
|
|
35 *
|
|
36 * Code:
|
|
37 *
|
|
38 */
|
|
39 /***********************************************************************
|
|
40 rk_alloc.c
|
|
41 88. 6.13 作 成
|
|
42
|
|
43 モード定義表、対応表の各要素数について、 限界値を
|
|
44 越えても大丈夫なように、テーブルのサイズを可変長に
|
|
45 したための新しい関数群
|
|
46 ***********************************************************************/
|
|
47 /* Version 3.1 88/06/14 H.HASHIMOTO
|
|
48 */
|
|
49 #ifndef OMRON_LIB
|
|
50 #include "rk_header.h"
|
|
51 #include "rk_extvars.h"
|
|
52 #ifdef MULTI
|
|
53 #include "rk_multi.h"
|
|
54 #endif /*MULTI*/
|
|
55 #endif
|
|
56 #include "rext.h"
|
|
57 static void
|
|
58 ERRALLOC (n)
|
|
59 unsigned int n;
|
|
60 {
|
|
61 fprintf (stderr, "\r\nromkan: ---\r\n");
|
|
62 fprintf (stderr, "\tError No.%d: Can't memory alloc.\r\n", n);
|
|
63 longjmp (cur_rk->env0, 1);
|
|
64 }
|
|
65
|
|
66 /* モード定義表の読み込みのための各種の管理テーブルの領域の獲得 */
|
|
67 #ifdef OMRON_LIB
|
|
68 static
|
|
69 #endif
|
|
70 void
|
|
71 malloc_for_modetable_struct (ptr, maxsize, memsize)
|
|
72 fast modetable *ptr;
|
|
73 int maxsize;
|
|
74 int memsize;
|
|
75 {
|
|
76 if ((ptr->max = maxsize) > 0)
|
|
77 {
|
|
78 if ((ptr->point = (char **) malloc (ptr->max * sizeof (char *))) == NULL)
|
|
79 {
|
|
80 ERRALLOC (0);
|
|
81 }
|
|
82 ptr->point[0] = NULL;
|
|
83 }
|
|
84 else
|
|
85 {
|
|
86 ptr->point = NULL;
|
|
87 }
|
|
88 ptr->count = 0;
|
|
89 if ((ptr->size = maxsize) > 0)
|
|
90 {
|
|
91 if ((ptr->org = ptr->next = (char *) malloc (ptr->size)) == NULL)
|
|
92 {
|
|
93 ERRALLOC (0);
|
|
94 }
|
|
95 ptr->org[0] = '\0';
|
|
96 }
|
|
97 else
|
|
98 {
|
|
99 ptr->org = ptr->next = NULL;
|
|
100 }
|
|
101 }
|
|
102
|
|
103 /* モード定義表の読み込みのための各種の管理テーブルの領域の開放 */
|
|
104 #ifdef OMRON_LIB
|
|
105 static
|
|
106 #endif
|
|
107 void
|
|
108 free_for_modetable_struct (ptr)
|
|
109 fast modetable *ptr;
|
|
110 {
|
|
111 if (ptr->point != NULL)
|
|
112 {
|
|
113 free (ptr->point);
|
|
114 ptr->max = ptr->count = 0;
|
|
115 ptr->point = NULL;
|
|
116 }
|
|
117 if (ptr->org != NULL)
|
|
118 {
|
|
119 free (ptr->org);
|
|
120 ptr->size = 0;
|
|
121 ptr->org = ptr->next = NULL;
|
|
122 }
|
|
123 }
|
|
124
|
|
125 /* モード定義表の読み込みのための各種の管理テーブルの領域のチェック */
|
|
126 #ifdef OMRON_LIB
|
|
127 static
|
|
128 #endif
|
|
129 void
|
|
130 check_and_realloc_for_modetable_struct (ptr, n, s, maxsize, memsize)
|
|
131 fast modetable *ptr;
|
|
132 int n;
|
|
133 char *s;
|
|
134 int maxsize;
|
|
135 int memsize;
|
|
136 {
|
|
137 fast int i;
|
|
138 fast int ptrdiff;
|
|
139 fast char *oldptr;
|
|
140
|
|
141 if ((ptr->count = n + 1) > ptr->max)
|
|
142 {
|
|
143 if ((ptr->max += maxsize) > 0)
|
|
144 {
|
|
145 if (ptr->point == NULL)
|
|
146 {
|
|
147 if ((ptr->point = (char **) malloc (ptr->max * sizeof (char *))) == NULL)
|
|
148 {
|
|
149 ERRALLOC (0);
|
|
150 }
|
|
151 }
|
|
152 else
|
|
153 {
|
|
154 if ((ptr->point = (char **) realloc (ptr->point, ptr->max * sizeof (char *))) == NULL)
|
|
155 {
|
|
156 ERRALLOC (0);
|
|
157 }
|
|
158 }
|
|
159 }
|
|
160 }
|
|
161 while ((ptr->org + ptr->size) < (ptr->next + strlen (s) + 1))
|
|
162 {
|
|
163 if ((ptr->org = (char *) realloc (oldptr = ptr->org, ptr->size += memsize)) == NULL)
|
|
164 {
|
|
165 ERRALLOC (0);
|
|
166 }
|
|
167 ptr->next += (ptrdiff = ptr->org - oldptr);
|
|
168 for (i = 0; i < n; i++)
|
|
169 {
|
|
170 ptr->point[i] += ptrdiff;
|
|
171 }
|
|
172 }
|
|
173 }
|
|
174
|
|
175 /* モードの on, off のスイッチテーブルの獲得 */
|
|
176 #ifdef OMRON_LIB
|
|
177 static
|
|
178 #endif
|
|
179 void
|
|
180 malloc_for_modesw (ptr, size)
|
|
181 fast modeswtable *ptr;
|
|
182 int size;
|
|
183 {
|
|
184 if ((ptr->max = size) > 0)
|
|
185 {
|
|
186 if ((ptr->point = (int *) malloc (ptr->max * sizeof (int))) == NULL)
|
|
187 {
|
|
188 ERRALLOC (0);
|
|
189 }
|
|
190 }
|
|
191 else
|
|
192 {
|
|
193 ptr->point = NULL;
|
|
194 }
|
|
195 ptr->count = 0;
|
|
196 }
|
|
197
|
|
198 /* モードの on, off のスイッチテーブルの解放 */
|
|
199 #ifdef OMRON_LIB
|
|
200 static
|
|
201 #endif
|
|
202 void
|
|
203 free_for_modesw (ptr)
|
|
204 fast modeswtable *ptr;
|
|
205 {
|
|
206 if (ptr->point != NULL)
|
|
207 {
|
|
208 free (ptr->point);
|
|
209 ptr->max = ptr->count = 0;
|
|
210 ptr->point = NULL;
|
|
211 }
|
|
212 }
|
|
213
|
|
214 /* モードの on, off のスイッチテーブルのサイズチェック */
|
|
215 #ifdef OMRON_LIB
|
|
216 static
|
|
217 #endif
|
|
218 void
|
|
219 check_and_realloc_for_modesw (ptr, n, size)
|
|
220 fast modeswtable *ptr;
|
|
221 int n;
|
|
222 int size;
|
|
223 {
|
|
224 if ((ptr->count = n + 1) > ptr->max)
|
|
225 {
|
|
226 if ((ptr->max += size) > 0)
|
|
227 {
|
|
228 if (ptr->point == NULL)
|
|
229 {
|
|
230 if ((ptr->point = (int *) malloc (ptr->max * sizeof (int))) == NULL)
|
|
231 {
|
|
232 ERRALLOC (0);
|
|
233 }
|
|
234 }
|
|
235 else
|
|
236 {
|
|
237 if ((ptr->point = (int *) realloc (ptr->point, ptr->max * sizeof (int))) == NULL)
|
|
238 {
|
|
239 ERRALLOC (0);
|
|
240 }
|
|
241 }
|
|
242 }
|
|
243 }
|
|
244 }
|
|
245
|
|
246 /* モード定義表の読み込みのための領域の獲得 */
|
|
247 #ifdef OMRON_LIB
|
|
248 static
|
|
249 #endif
|
|
250 void
|
|
251 malloc_for_modebuf (ptr, size)
|
|
252 fast modebuftable *ptr;
|
|
253 int size;
|
|
254 {
|
|
255 if ((ptr->org = (char *) malloc (ptr->size = size + 1)) == NULL)
|
|
256 {
|
|
257 ERRALLOC (0);
|
|
258 }
|
|
259 }
|
|
260
|
|
261 /* モード定義表の読み込みのための領域の解放 */
|
|
262 #ifdef OMRON_LIB
|
|
263 static
|
|
264 #endif
|
|
265 void
|
|
266 free_for_modebuf (ptr)
|
|
267 fast modebuftable *ptr;
|
|
268 {
|
|
269 if (ptr->org != NULL)
|
|
270 {
|
|
271 free (ptr->org);
|
|
272 ptr->size = 0;
|
|
273 ptr->org = NULL;
|
|
274 }
|
|
275 }
|
|
276
|
|
277 /* モード表の内部形式のテーブルの獲得 */
|
|
278 #ifdef OMRON_LIB
|
|
279 static
|
|
280 #endif
|
|
281 void
|
|
282 malloc_for_modenaibu (ptr, size)
|
|
283 fast modenaibutable *ptr;
|
|
284 int size;
|
|
285 {
|
|
286 if ((ptr->org = ptr->next = (int *) malloc ((ptr->size = size + 1) * sizeof (int))) == NULL)
|
|
287 {
|
|
288 ERRALLOC (0);
|
|
289 }
|
|
290 }
|
|
291
|
|
292 /* モード表の内部形式のテーブルのサイズ変更 */
|
|
293 #ifdef OMRON_LIB
|
|
294 static
|
|
295 #endif
|
|
296 void
|
|
297 realloc_for_modenaibu (ptr)
|
|
298 fast modenaibutable *ptr;
|
|
299 {
|
|
300 if ((ptr->org = (int *) realloc (ptr->org, (ptr->size = ptr->next - ptr->org + 1) * sizeof (int))) == NULL)
|
|
301 {
|
|
302 ERRALLOC (0);
|
|
303 }
|
|
304 }
|
|
305
|
|
306 /* モード表の内部形式のテーブルの解放 */
|
|
307 #ifdef OMRON_LIB
|
|
308 static
|
|
309 #endif
|
|
310 void
|
|
311 free_for_modenaibu (ptr)
|
|
312 fast modenaibutable *ptr;
|
|
313 {
|
|
314 if (ptr->org != NULL)
|
|
315 {
|
|
316 free (ptr->org);
|
|
317 ptr->size = 0;
|
|
318 ptr->org = ptr->next = NULL;
|
|
319 }
|
|
320 }
|
|
321
|
|
322 /* 対応表の管理テーブルの領域の獲得 */
|
|
323 #ifdef OMRON_LIB
|
|
324 static
|
|
325 #endif
|
|
326 void
|
|
327 malloc_for_hyo (ptr, size)
|
|
328 fast hyotable *ptr;
|
|
329 int size; /* 対応表の総数 */
|
|
330 {
|
|
331 hyo *hyoptr;
|
|
332 fast int i;
|
|
333
|
|
334 if ((ptr->size = size) > 0)
|
|
335 {
|
|
336 if ((ptr->point = (hyo *) malloc (ptr->size * sizeof (hyo))) == NULL)
|
|
337 {
|
|
338 ERRALLOC (0);
|
|
339 }
|
|
340 for (i = 0, hyoptr = ptr->point; i < size; i++, hyoptr++)
|
|
341 {
|
|
342 hyoptr->hyoshu = 0;
|
|
343 hyoptr->data = NULL;
|
|
344 hyoptr->hensudef = NULL;
|
|
345 hyoptr->size = 0;
|
|
346 hyoptr->memory = NULL;
|
|
347 }
|
|
348 }
|
|
349 else
|
|
350 {
|
|
351 ptr->point = NULL;
|
|
352 }
|
|
353 }
|
|
354
|
|
355 /* 対応表の管理テーブルの領域の解放 */
|
|
356 #ifdef OMRON_LIB
|
|
357 static
|
|
358 #endif
|
|
359 void
|
|
360 free_for_hyo (ptr)
|
|
361 fast hyotable *ptr;
|
|
362 {
|
|
363 if (ptr->point != NULL)
|
|
364 {
|
|
365 free (ptr->point);
|
|
366 ptr->size = 0;
|
|
367 ptr->point = NULL;
|
|
368 }
|
|
369 }
|
|
370
|
|
371 /* 前・本・後処理の対応表の管理テーブルの領域の獲得 */
|
|
372 #ifdef OMRON_LIB
|
|
373 static
|
|
374 #endif
|
|
375 void
|
|
376 malloc_for_usehyo (ptr, size)
|
|
377 fast usehyotable *ptr;
|
|
378 int size; /* 対応表の総数 */
|
|
379 {
|
|
380 if ((ptr->usemaehyo = (int *) malloc (((ptr->size = size) + 1) * sizeof (int) * 3)) == NULL)
|
|
381 {
|
|
382 ERRALLOC (0);
|
|
383 }
|
|
384 ptr->usehyo = (int *) (ptr->usemaehyo) + ptr->size + 1;
|
|
385 ptr->useatohyo = (int *) (ptr->usehyo) + ptr->size + 1;
|
|
386 }
|
|
387
|
|
388 /* 前・本・後処理の対応表の管理テーブルの領域の解放 */
|
|
389 #ifdef OMRON_LIB
|
|
390 static
|
|
391 #endif
|
|
392 void
|
|
393 free_for_usehyo (ptr)
|
|
394 fast usehyotable *ptr;
|
|
395 {
|
|
396 if (ptr->usemaehyo != NULL)
|
|
397 {
|
|
398 free (ptr->usemaehyo);
|
|
399 ptr->size = 0;
|
|
400 ptr->usemaehyo = ptr->usehyo = ptr->useatohyo = NULL;
|
|
401 }
|
|
402 }
|
|
403
|
|
404 /* 対応表の実データテーブルの領域の獲得 */
|
|
405 #ifdef OMRON_LIB
|
|
406 static
|
|
407 #endif
|
|
408 void
|
|
409 malloc_for_hyo_area (ptr, n, datasize, memsize, dataptrp, memptrp)
|
|
410 fast hyotable *ptr;
|
|
411 fast int n; /* 対応表の番号 */
|
|
412 int datasize;
|
|
413 int memsize;
|
|
414 dat **dataptrp;
|
|
415 letter **memptrp;
|
|
416 {
|
|
417 if ((*dataptrp = ptr->point[n].data = (dat *) malloc ((datasize + 1) * sizeof (dat))) == NULL)
|
|
418 {
|
|
419 ERRALLOC (0);
|
|
420 }
|
|
421 if ((*memptrp = ptr->point[n].memory = (letter *) malloc ((ptr->point[n].size = memsize + 1) * sizeof (letter))) == NULL)
|
|
422 {
|
|
423 ERRALLOC (0);
|
|
424 }
|
|
425 }
|
|
426
|
|
427 /* 対応表の実データテーブルの領域の獲得 */
|
|
428 #ifdef OMRON_LIB
|
|
429 static
|
|
430 #endif
|
|
431 void
|
|
432 free_for_hyo_area (ptr, n)
|
|
433 fast hyotable *ptr;
|
|
434 fast int n; /* 対応表の番号 */
|
|
435 {
|
|
436 if (ptr->point[n].data != NULL)
|
|
437 {
|
|
438 free (ptr->point[n].data);
|
|
439 ptr->point[n].data = NULL;
|
|
440 }
|
|
441 if (ptr->point[n].memory != NULL)
|
|
442 {
|
|
443 free (ptr->point[n].memory);
|
|
444 ptr->point[n].memory = NULL;
|
|
445 }
|
|
446 }
|
|
447
|
|
448 /* 全対応表の変数の管理テーブルの獲得 */
|
|
449 #ifdef OMRON_LIB
|
|
450 static
|
|
451 #endif
|
|
452 void
|
|
453 malloc_for_hensuudef (ptr, size)
|
|
454 fast hensuudeftable *ptr;
|
|
455 int size;
|
|
456 {
|
|
457 if ((ptr->max = size) > 0)
|
|
458 {
|
|
459 if ((ptr->point = (letter **) malloc (ptr->max * sizeof (letter *))) == NULL)
|
|
460 {
|
|
461 ERRALLOC (0);
|
|
462 }
|
|
463 }
|
|
464 else
|
|
465 {
|
|
466 ptr->point = NULL;
|
|
467 }
|
|
468 ptr->count = 0;
|
|
469 }
|
|
470
|
|
471 /* 全対応表の変数の管理テーブルの解放 */
|
|
472 #ifdef OMRON_LIB
|
|
473 static
|
|
474 #endif
|
|
475 void
|
|
476 free_for_hensuudef (ptr)
|
|
477 fast hensuudeftable *ptr;
|
|
478 {
|
|
479 if (ptr->point != NULL)
|
|
480 {
|
|
481 free (ptr->point);
|
|
482 ptr->max = ptr->count = 0;
|
|
483 ptr->point = NULL;
|
|
484 }
|
|
485 }
|
|
486
|
|
487 /* 全対応表の変数の管理テーブルの解放 */
|
|
488 #ifdef OMRON_LIB
|
|
489 static
|
|
490 #endif
|
|
491 void
|
|
492 check_and_realloc_for_hensuudef (ptr, n, size)
|
|
493 fast hensuudeftable *ptr;
|
|
494 int n;
|
|
495 int size;
|
|
496 {
|
|
497 if ((ptr->count = n + 1) > ptr->max)
|
|
498 {
|
|
499 if ((ptr->max += size) > 0)
|
|
500 {
|
|
501 if (ptr->point == NULL)
|
|
502 {
|
|
503 if ((ptr->point = (letter **) malloc (ptr->max * sizeof (letter *))) == NULL)
|
|
504 {
|
|
505 ERRALLOC (0);
|
|
506 }
|
|
507 }
|
|
508 else
|
|
509 {
|
|
510 if ((ptr->point = (letter **) realloc (ptr->point, ptr->max * sizeof (letter *))) == NULL)
|
|
511 {
|
|
512 ERRALLOC (0);
|
|
513 }
|
|
514 }
|
|
515 }
|
|
516 }
|
|
517 }
|
|
518
|
|
519 /* 対応表の変数の管理テーブルの獲得 */
|
|
520 #ifdef OMRON_LIB
|
|
521 static
|
|
522 #endif
|
|
523 void
|
|
524 malloc_for_hensuu (ptr, maxsize, memsize)
|
|
525 fast hensuutable *ptr;
|
|
526 int maxsize;
|
|
527 int memsize;
|
|
528 {
|
|
529 if ((ptr->max = maxsize) > 0)
|
|
530 {
|
|
531 if ((ptr->point = (hensuset *) malloc (ptr->max * sizeof (hensuset))) == NULL)
|
|
532 {
|
|
533 ERRALLOC (0);
|
|
534 }
|
|
535 }
|
|
536 else
|
|
537 {
|
|
538 ptr->point = NULL;
|
|
539 }
|
|
540 ptr->count = 0;
|
|
541 if ((ptr->org = ptr->next = (letter *) malloc (((ptr->size = memsize) + 1) * sizeof (letter))) == NULL)
|
|
542 {
|
|
543 ERRALLOC (0);
|
|
544 }
|
|
545 }
|
|
546
|
|
547 /* 対応表の変数の管理テーブルの開放 */
|
|
548 #ifdef OMRON_LIB
|
|
549 static
|
|
550 #endif
|
|
551 void
|
|
552 free_for_hensuu (ptr)
|
|
553 fast hensuutable *ptr;
|
|
554 {
|
|
555 if (ptr->point != NULL)
|
|
556 {
|
|
557 free (ptr->point);
|
|
558 ptr->max = ptr->count = 0;
|
|
559 ptr->point = NULL;
|
|
560 }
|
|
561 if (ptr->org != NULL)
|
|
562 {
|
|
563 free (ptr->org);
|
|
564 ptr->size = 0;
|
|
565 ptr->org = ptr->next = NULL;
|
|
566 }
|
|
567 }
|
|
568
|
|
569 /* 対応表の変数の管理テーブルのサイズチェック */
|
|
570 #ifdef OMRON_LIB
|
|
571 static
|
|
572 #endif
|
|
573 void
|
|
574 check_and_realloc_for_hensuu (ptr, n, name, maxsize, memsize)
|
|
575 fast hensuutable *ptr;
|
|
576 int n;
|
|
577 letter *name;
|
|
578 int maxsize;
|
|
579 int memsize;
|
|
580 {
|
|
581 fast int i; /* V3.1 */
|
|
582 fast int ptrdiff; /* V3.1 */
|
|
583 fast letter *oldptr; /* V3.1 */
|
|
584
|
|
585 if ((ptr->count = n + 1) > ptr->max)
|
|
586 {
|
|
587 if ((ptr->max += memsize) > 0)
|
|
588 {
|
|
589 if (ptr->point == NULL)
|
|
590 {
|
|
591 if ((ptr->point = (hensuset *) malloc (ptr->max * sizeof (hensuset))) == NULL)
|
|
592 {
|
|
593 ERRALLOC (0);
|
|
594 }
|
|
595 }
|
|
596 else
|
|
597 {
|
|
598 if ((ptr->point = (hensuset *) realloc (ptr->point, ptr->max * sizeof (hensuset))) == NULL)
|
|
599 {
|
|
600 ERRALLOC (0);
|
|
601 }
|
|
602 }
|
|
603 }
|
|
604 }
|
|
605 while ((ptr->org + ptr->size) < (ptr->next + (ltrlen (name) + 1 + 1)))
|
|
606 {
|
|
607
|
|
608 if ((ptr->org = (letter *) realloc (oldptr = ptr->org, ((ptr->size += memsize) + 1) * sizeof (letter))) == NULL)
|
|
609 {
|
|
610 ERRALLOC (0);
|
|
611 }
|
|
612 ptr->next += (ptrdiff = ptr->org - oldptr);
|
|
613 for (i = 0; i < n; i++)
|
|
614 {
|
|
615 ptr->point[i].name += ptrdiff;
|
|
616 }
|
|
617 }
|
|
618 }
|
|
619
|
|
620 /* マッチした変数の管理テーブルの獲得 */
|
|
621 #ifdef OMRON_LIB
|
|
622 static
|
|
623 #endif
|
|
624 void
|
|
625 malloc_for_henmatch (ptr, size)
|
|
626 fast matchtable *ptr;
|
|
627 int size; /* 変数の総数 */
|
|
628 {
|
|
629 if ((ptr->size = size) > 0)
|
|
630 {
|
|
631 if ((ptr->point = (matchpair *) malloc (ptr->size * sizeof (matchpair))) == NULL)
|
|
632 {
|
|
633 ERRALLOC (0);
|
|
634 }
|
|
635 }
|
|
636 else
|
|
637 {
|
|
638 ptr->point = NULL;
|
|
639 }
|
|
640 }
|
|
641
|
|
642 /* マッチした変数の管理テーブルの解放 */
|
|
643 #ifdef OMRON_LIB
|
|
644 static
|
|
645 #endif
|
|
646 void
|
|
647 free_for_henmatch (ptr)
|
|
648 fast matchtable *ptr;
|
|
649 {
|
|
650 if (ptr->point != NULL)
|
|
651 {
|
|
652 free (ptr->point);
|
|
653 ptr->size = 0;
|
|
654 ptr->point = NULL;
|
|
655 }
|
|
656 }
|
|
657
|
|
658 /* 対応表を読み込むバッファの領域の獲得 */
|
|
659 #ifdef OMRON_LIB
|
|
660 static
|
|
661 #endif
|
|
662 void
|
|
663 malloc_for_hyobuf (ptr, size)
|
|
664 fast hyobuftable *ptr;
|
|
665 int size;
|
|
666 {
|
|
667 if ((ptr->size = size) > 0)
|
|
668 {
|
|
669 if ((ptr->org = ptr->next = (char *) malloc (ptr->size)) == NULL || (ptr->tmp = (char *) malloc (ptr->size)) == NULL)
|
|
670 {
|
|
671 ERRALLOC (0);
|
|
672 }
|
|
673 }
|
|
674 else
|
|
675 {
|
|
676 ptr->org = NULL;
|
|
677 }
|
|
678 }
|
|
679
|
|
680 /* 対応表を読み込むバッファの領域の開放 */
|
|
681 #ifdef OMRON_LIB
|
|
682 static
|
|
683 #endif
|
|
684 void
|
|
685 free_for_hyobuf (ptr)
|
|
686 fast hyobuftable *ptr;
|
|
687 {
|
|
688 if (ptr->org != NULL)
|
|
689 {
|
|
690 free (ptr->org);
|
|
691 ptr->size = 0;
|
|
692 ptr->org = ptr->next = NULL;
|
|
693 }
|
|
694 }
|
|
695
|
|
696 /* 対応表を読み込むバッファの領域のサイズチェック */
|
|
697 #ifdef OMRON_LIB
|
|
698 static
|
|
699 #endif
|
|
700 void
|
|
701 check_and_realloc_for_hyobuf (ptr, size)
|
|
702 fast hyobuftable *ptr;
|
|
703 int size;
|
|
704 {
|
|
705 /* 対応表の読み込み */
|
|
706 if ((size + 2) > ptr->size)
|
|
707 {
|
|
708 if (ptr->org == NULL)
|
|
709 {
|
|
710 if ((ptr->org = (char *) malloc (ptr->size = size + 2)) == NULL || (ptr->tmp = (char *) malloc (ptr->size = size + 2)) == NULL)
|
|
711 {
|
|
712 ERRALLOC (0);
|
|
713 }
|
|
714 }
|
|
715 else
|
|
716 {
|
|
717 if ((ptr->org = (char *) realloc (ptr->org, ptr->size = size + 2)) == NULL || (ptr->tmp = (char *) realloc (ptr->tmp, ptr->size = size + 2)) == NULL)
|
|
718 {
|
|
719 ERRALLOC (0);
|
|
720 }
|
|
721 }
|
|
722 }
|
|
723 }
|
|
724
|
|
725 /* 変数の変域のワーク領域の獲得 */
|
|
726 #ifdef OMRON_LIB
|
|
727 static
|
|
728 #endif
|
|
729 void
|
|
730 malloc_for_heniki (ptr, size)
|
|
731 fast henikitable *ptr;
|
|
732 int size;
|
|
733 {
|
|
734 if ((ptr->org = (letter *) malloc ((ptr->size = size + 1) * sizeof (letter))) == NULL)
|
|
735 {
|
|
736 ERRALLOC (0);
|
|
737 }
|
|
738 }
|
|
739
|
|
740 /* 変数の変域のワーク領域の開放 */
|
|
741 #ifdef OMRON_LIB
|
|
742 static
|
|
743 #endif
|
|
744 void
|
|
745 free_for_heniki (ptr)
|
|
746 fast henikitable *ptr;
|
|
747 {
|
|
748 if (ptr->org != NULL)
|
|
749 {
|
|
750 free (ptr->org);
|
|
751 ptr->size = 0;
|
|
752 ptr->org = NULL;
|
|
753 }
|
|
754 }
|
|
755
|
|
756 /* 変数の変域のワーク領域のサイズチェック */
|
|
757 #ifdef OMRON_LIB
|
|
758 static
|
|
759 #endif
|
|
760 void
|
|
761 check_and_realloc_for_heniki (ptr, size)
|
|
762 fast henikitable *ptr;
|
|
763 int size;
|
|
764 {
|
|
765 if ((size + 1) > ptr->size)
|
|
766 {
|
|
767 if (ptr->org == NULL)
|
|
768 {
|
|
769 if ((ptr->org = (letter *) malloc ((ptr->size = size + 1) * sizeof (letter))) == NULL)
|
|
770 {
|
|
771 ERRALLOC (0);
|
|
772 }
|
|
773 }
|
|
774 else
|
|
775 {
|
|
776 if ((ptr->org = (letter *) realloc (ptr->org, (ptr->size = size + 1) * sizeof (letter))) == NULL)
|
|
777 {
|
|
778 ERRALLOC (0);
|
|
779 }
|
|
780 }
|
|
781 }
|
|
782 }
|