]> git.pld-linux.org Git - packages/Wnn6-SDK.git/blob - Wnn6-SDK-malloc.patch
rel 14
[packages/Wnn6-SDK.git] / Wnn6-SDK-malloc.patch
1 diff -uNr Xsi.orig/Wnn/etc/bdic.c Xsi/Wnn/etc/bdic.c
2 --- Xsi.orig/Wnn/etc/bdic.c     Wed Oct 28 13:36:16 1998
3 +++ Xsi/Wnn/etc/bdic.c  Tue Nov 10 05:17:21 1998
4 @@ -1849,7 +1851,7 @@
5      hjt.hindo_area = (int)((serial + MAX_HINDO_DATA_AREA - 1) / MAX_HINDO_DATA_AREA);
6      if(hjt.hindo_area != 0) {
7         if((hjt.curserial = (unsigned char *)
8 -               malloc(hjt.hindo_area * sizeof(unsigned char))) == NULL)
9 +               malloc0(hjt.hindo_area * sizeof(unsigned char))) == NULL)
10              return(-1);
11         for(i = 0; i < hjt.hindo_area; i++) (hjt.curserial)[i] = 0;
12      } else
13 @@ -1977,7 +1979,7 @@
14          return(-1);
15      if(hjt1->hindo_area != 0) {
16         if((hjt1->curserial = (unsigned char *)
17 -               malloc(hjt1->hindo_area * sizeof(unsigned char))) == NULL)
18 +               malloc0(hjt1->hindo_area * sizeof(unsigned char))) == NULL)
19              return(-1);
20         for(i = 0; i < hjt1->hindo_area; i++)
21             (hjt1->curserial)[i] = vgetc(ifpter, args);
22 diff -uNr Xsi.orig/Wnn/etc/fi_bdic.c Xsi/Wnn/etc/fi_bdic.c
23 --- Xsi.orig/Wnn/etc/fi_bdic.c  Wed Oct 28 13:36:17 1998
24 +++ Xsi/Wnn/etc/fi_bdic.c       Tue Nov 10 05:17:02 1998
25 @@ -179,6 +179,7 @@
26            putnull();
27  #endif /* Not JS */
28  
29 +extern  char    *malloc0();
30  
31  
32  #ifndef JS
33 @@ -215,7 +216,7 @@
34      /* ÀܳÄêµÁ£×£î£î¼­½ñ f_uniq ÇÛÎó¤ÎÆɤ߹þ¤ß */
35      if(jt1->maxjisho) {
36         if((jt1->jisho_uniq = (struct wnn_file_uniq *)
37 -           malloc(jt1->maxjisho * sizeof(struct wnn_file_uniq))) == NULL)
38 +           malloc0(jt1->maxjisho * sizeof(struct wnn_file_uniq))) == NULL)
39              return(-1);
40         for(i = 0; i < jt1->maxjisho; i++) {
41             if(input_file_uniq(&((jt1->jisho_uniq)[i]), ifpter, args) == -1)
42 diff -uNr Xsi.orig/Wnn/etc/gethinsi.c Xsi/Wnn/etc/gethinsi.c
43 --- Xsi.orig/Wnn/etc/gethinsi.c Wed Oct 28 13:36:17 1998
44 +++ Xsi/Wnn/etc/gethinsi.c      Tue Nov 10 05:12:15 1998
45 @@ -210,6 +210,9 @@
46  extern char *hinsi_file_name;
47  #endif /* !DSERVER && JSERVER */
48  
49 +extern char    *malloc0();
50 +extern void    free0();
51 +
52  static void
53  error_long(args)
54  ARGS *args;
55 @@ -622,7 +625,7 @@
56      struct HDT *hdata;
57      static int wnn_find_load_hinsi_by_name();
58  
59 -    if((hdata = (struct HDT *)malloc(sizeof(struct HDT))) == NULL) {
60 +    if((hdata = (struct HDT *)malloc0(sizeof(struct HDT))) == NULL) {
61         return(-1);
62      }
63      hp = heap = hdata->heap;
64 @@ -701,7 +704,7 @@
65  
66      return(0);
67   err:
68 -    free(hdata);
69 +    free0(hdata);
70      return(HINSI_ERR);
71  }
72  
73 diff -uNr Xsi.orig/Wnn/etc/msg.c Xsi/Wnn/etc/msg.c
74 --- Xsi.orig/Wnn/etc/msg.c      Wed Oct 28 13:36:18 1998
75 +++ Xsi/Wnn/etc/msg.c   Tue Nov 10 05:13:39 1998
76 @@ -160,6 +160,9 @@
77  
78  extern char *getenv();
79  
80 +extern char *malloc0();
81 +extern void free0();
82 +
83  static char *
84  bsearch(ky, bs, nel, width, compar)
85  char *ky;
86 @@ -386,7 +389,7 @@
87         }
88      }
89  
90 -    if (!(cd = (struct msg_cat *)malloc(sizeof(struct msg_cat))))
91 +    if (!(cd = (struct msg_cat *)malloc0(sizeof(struct msg_cat))))
92         return(NULL);
93  
94      strcpy(cd->name, name);
95 @@ -415,9 +418,9 @@
96  
97      cd->msg_cnt = msg_cnt;
98      if (!(bd = cd->msg_bd = (struct msg_bd *)
99 -              malloc((sizeof(struct msg_bd)) * msg_cnt + msg_byte + 1))) {
100 +              malloc0((sizeof(struct msg_bd)) * msg_cnt + msg_byte + 1))) {
101         fclose(fp);
102 -       free(cd);
103 +       free0(cd);
104         return(NULL);
105      }
106      msg = (char *) bd + (sizeof(struct msg_bd)) * msg_cnt;
107 @@ -489,9 +492,9 @@
108      if(cd->nextp)
109         msg_close(cd->nextp);
110      if(cd->msg_bd)
111 -       free(cd->msg_bd);
112 +       free0(cd->msg_bd);
113      if(cd)
114 -       free(cd);
115 +       free0(cd);
116  }
117  
118  #ifdef not_use
119 diff -uNr Xsi.orig/Wnn/jlib/jl.c Xsi/Wnn/jlib/jl.c
120 --- Xsi.orig/Wnn/jlib/jl.c      Wed Oct 28 13:36:30 1998
121 +++ Xsi/Wnn/jlib/jl.c   Tue Nov 10 05:07:39 1998
122 @@ -166,6 +166,9 @@
123  #include "wnn_string.h"
124  extern struct msg_cat *wnn_msg_cat;
125  
126 +extern char    *malloc0();
127 +extern void    free0();
128 +extern char    *realloc0();
129  
130  #define MAXENVS WNN_MAX_ENV_OF_A_CLIENT
131  
132 @@ -480,7 +483,7 @@
133  register char *name;
134  {
135      register struct wnn_file_name_id *f, *f1;
136 -    if((f = (struct wnn_file_name_id *)malloc(sizeof(struct wnn_file_name_id) +
137 +    if((f = (struct wnn_file_name_id *)malloc0(sizeof(struct wnn_file_name_id) +
138                                              strlen(name) + 1)) == NULL){
139         env_wnn_errorno_set=WNN_ALLOC_FAIL;
140         return(-1);
141 @@ -529,7 +532,7 @@
142      for(prev = &jl_env_p->file; (f = *prev); prev = &f->next){
143         if (f->id == id) {
144             *prev = f->next;
145 -           free(f);
146 +           free0(f);
147             UnlockMutex(&envs_lock);
148             return(0);
149         }
150 @@ -774,10 +777,10 @@
151      struct wnn_env *env;
152  
153      wnn_errorno = 0;
154 -    if(rb.size == 0) rb.buf = (char *)malloc((unsigned)(rb.size = 1024));
155 +    if(rb.size == 0) rb.buf = (char *)malloc0((unsigned)(rb.size = 1024));
156  
157  #define ALLOC_SET(pter, type, size, size_var) \
158 -    ((pter) = ((type *)malloc((unsigned)(sizeof(type) * ((size_var) = (size))))))
159 +    ((pter) = ((type *)malloc0((unsigned)(sizeof(type) * ((size_var) = (size))))))
160  
161      if(!ALLOC_SET(buf, struct wnn_buf_mt, 1, dmy)){
162         wnn_errorno=WNN_ALLOC_FAIL;return NULL;
163 @@ -884,7 +887,7 @@
164      char **c;
165      register WNN_BUN *d;
166  
167 -    if((c =(char **)malloc((unsigned)(len * sizeof(WNN_BUN) + sizeof(char *)))) == NULL){
168 +    if((c =(char **)malloc0((unsigned)(len * sizeof(WNN_BUN) + sizeof(char *)))) == NULL){
169             buf_wnn_errorno_set=WNN_ALLOC_FAIL;
170         return(-1);
171      }
172 @@ -918,15 +921,15 @@
173         buf->env = 0;
174      }
175  
176 -    if(buf->bun) free((char *)buf->bun);
177 -    if(buf->zenkouho) free((char *)buf->zenkouho);
178 -    if(buf->zenkouho_dai) free((char *)buf->zenkouho_dai);
179 -    if(buf->down_bnst) free((char *)buf->down_bnst);
180 +    if(buf->bun) free0((char *)buf->bun);
181 +    if(buf->zenkouho) free0((char *)buf->zenkouho);
182 +    if(buf->zenkouho_dai) free0((char *)buf->zenkouho_dai);
183 +    if(buf->down_bnst) free0((char *)buf->down_bnst);
184      for(c = buf->heap; c; c = next) {
185         next = *(char **)c;
186 -       free(c);
187 +       free0(c);
188      }
189 -    free((char *)buf);
190 +    free0((char *)buf);
191      UnlockMutex(&(tmpbuf.buf_lock));
192  }
193  
194 @@ -1027,11 +1030,11 @@
195      }
196      if(nhinsi) {
197          hsize = abs(nhinsi);
198 -        hno = (int *)malloc(hsize * sizeof(int));
199 +        hno = (int *)malloc0(hsize * sizeof(int));
200          for(i = 0; i < hsize; i++) {
201              _Sstrcpy(tmp, hname[i]);
202              if((hno[i] = jl_hinsi_number_e(buf->env, tmp)) == -1) {
203 -                free((char *)hno);
204 +                free0((char *)hno);
205                  UnlockMutex(&BUF_LOCK(buf));
206                  return(-1);
207              }
208 @@ -1040,7 +1043,7 @@
209  
210      x = ren_conv_sub((WNN_BUF_MT *)buf, yomi, bun_no, bun_no2, use_maep,
211                      0, nhinsi, hno, 0);
212 -    if(nhinsi) free((char *)hno);
213 +    if(nhinsi) free0((char *)hno);
214      UnlockMutex(&BUF_LOCK(buf));
215      return x;
216  } /* End of jl_ren_conv_with_hinsi_name */
217 @@ -1422,11 +1425,11 @@
218      } */
219      if(nhinsi) {
220         hsize = abs(nhinsi);
221 -       hno = (int *)malloc(hsize * sizeof(int));
222 +       hno = (int *)malloc0(hsize * sizeof(int));
223         for(i = 0; i < hsize; i++) {
224             _Sstrcpy(tmp, hname[i]);
225             if((hno[i] = jl_hinsi_number_e(buf->env, tmp)) == -1) {
226 -               free((char *)hno);
227 +               free0((char *)hno);
228                 UnlockMutex(&BUF_LOCK(buf));
229                 return(-1);
230             }
231 @@ -1435,11 +1438,11 @@
232  
233      if(tan_conv_sub((WNN_BUF_MT *)buf, yomi, bun_no, bun_no2, use_maep,
234                     ich_shop, 0, nhinsi, hno) == -1) {
235 -       if(nhinsi) free((char *)hno);
236 +       if(nhinsi) free0((char *)hno);
237          UnlockMutex(&BUF_LOCK(buf));
238          return(-1);
239      }
240 -    if(nhinsi) free((char *)hno);
241 +    if(nhinsi) free0((char *)hno);
242      x = buf->bun_suu;
243      UnlockMutex(&BUF_LOCK(buf));
244      return x;
245 @@ -1767,11 +1770,11 @@
246      } */
247      if(nhinsi) {
248         hsize = abs(nhinsi);
249 -       hno = (int *)malloc(hsize * sizeof(int));
250 +       hno = (int *)malloc0(hsize * sizeof(int));
251         for(i = 0; i < hsize; i++) {
252             _Sstrcpy(tmp, hname[i]);
253             if((hno[i] = jl_hinsi_number_e(buf->env, tmp)) == -1) {
254 -               free((char *)hno);
255 +               free0((char *)hno);
256                 UnlockMutex(&BUF_LOCK(buf));
257                 return(-1);
258             }
259 @@ -1780,11 +1783,11 @@
260  
261      if(nobi_conv_sub(buf, bun_no, ichbn_len, bun_no2, use_maep, ich_shop,
262                      nhinsi, hno, 0) == -1) {
263 -       if(nhinsi) free((char *)hno);
264 +       if(nhinsi) free0((char *)hno);
265         UnlockMutex(&BUF_LOCK(buf));
266         return(-1);
267      }
268 -    if(nhinsi) free((char *)hno);
269 +    if(nhinsi) free0((char *)hno);
270      x = buf->bun_suu;
271      UnlockMutex(&BUF_LOCK(buf));
272      return x;
273 @@ -2206,18 +2209,18 @@
274      } */
275      if(nhinsi){
276         hsize = abs(nhinsi);
277 -       hno = (int *)malloc(hsize * sizeof(int));
278 +       hno = (int *)malloc0(hsize * sizeof(int));
279         for(i = 0; i < hsize; i++) {
280             _Sstrcpy(tmp, hname[i]);
281             if((hno[i] = jl_hinsi_number_e(buf->env, tmp)) == -1) {
282 -               free((char *)hno);
283 +               free0((char *)hno);
284                 UnlockMutex(&BUF_LOCK(buf));
285                 return(-1);
286             }
287         }
288      }
289      x = zen_conv_sho1(buf, bun_no, use_maep, uniq_level, 0, nhinsi, hno);
290 -    if(nhinsi) free((char *)hno);
291 +    if(nhinsi) free0((char *)hno);
292      UnlockMutex(&BUF_LOCK(buf));
293      return x;
294  }
295 @@ -2431,18 +2434,18 @@
296         } */
297      if(nhinsi){
298          hsize = abs(nhinsi);
299 -        hno = (int *)malloc(hsize * sizeof(int));
300 +        hno = (int *)malloc0(hsize * sizeof(int));
301          for(i = 0; i < hsize; i++) {
302              _Sstrcpy(tmp, hname[i]);
303              if((hno[i] = jl_hinsi_number_e(buf->env, tmp)) == -1) {
304 -                free((char *)hno);
305 +                free0((char *)hno);
306                  UnlockMutex(&BUF_LOCK(buf));
307                  return(-1);
308              }
309          }
310      }
311      x = zen_conv_dai1(buf, bun_no, bun_no2, use_maep, uniq_level, 0, nhinsi, hno);
312 -    if(nhinsi) free((char *)hno);
313 +    if(nhinsi) free0((char *)hno);
314      UnlockMutex(&BUF_LOCK(buf));
315      return x;
316  }
317 @@ -3175,46 +3178,46 @@
318      /* Á°³ÎÄêʸÀá¾ðÊóʬ¤ò³ÎÄê¸õÊä¿ô¤Ë²Ã¤¨¤ë */
319      nkouho = bun_no2 - bun_no + WNN_PREV_BUN_SUU;
320  
321 -    if ( (dic = (int *)malloc(nkouho * sizeof(int))) == NULL )
322 +    if ( (dic = (int *)malloc0(nkouho * sizeof(int))) == NULL )
323        return(-1);
324  
325 -    if ( (entry = (int *)malloc(nkouho * sizeof(int))) == NULL ) {
326 -      free(dic);
327 +    if ( (entry = (int *)malloc0(nkouho * sizeof(int))) == NULL ) {
328 +      free0(dic);
329        return(-1);
330      }
331 -    if ( (ima = (int *)malloc(nkouho * sizeof(int))) == NULL ) {
332 -      free(dic);
333 -      free(entry);
334 +    if ( (ima = (int *)malloc0(nkouho * sizeof(int))) == NULL ) {
335 +      free0(dic);
336 +      free0(entry);
337        return(-1);
338      }
339 -    if ( (hindo = (int *)malloc(nkouho * sizeof(int))) == NULL ) {
340 -      free(dic);
341 -      free(entry);
342 -      free(ima);
343 +    if ( (hindo = (int *)malloc0(nkouho * sizeof(int))) == NULL ) {
344 +      free0(dic);
345 +      free0(entry);
346 +      free0(ima);
347        return(-1);
348      }
349 -    if ( (kmoji = (int *)malloc(nkouho * sizeof(int))) == NULL ) {
350 -      free(dic);
351 -      free(entry);
352 -      free(ima);
353 -      free(hindo);
354 +    if ( (kmoji = (int *)malloc0(nkouho * sizeof(int))) == NULL ) {
355 +      free0(dic);
356 +      free0(entry);
357 +      free0(ima);
358 +      free0(hindo);
359        return(-1);
360      }
361 -    if ( (kouho = (w_char **)malloc(nkouho * sizeof(w_char *))) == NULL ) {
362 -      free(dic);
363 -      free(entry);
364 -      free(ima);
365 -      free(hindo);
366 -      free(kmoji);
367 +    if ( (kouho = (w_char **)malloc0(nkouho * sizeof(w_char *))) == NULL ) {
368 +      free0(dic);
369 +      free0(entry);
370 +      free0(ima);
371 +      free0(hindo);
372 +      free0(kmoji);
373        return(-1);
374      }
375 -    if ( (tmp = (w_char *)malloc(nkouho * sizeof(w_char) * LENGTHKANJI)) == NULL ) {
376 -      free(dic);
377 -      free(entry);
378 -      free(ima);
379 -      free(hindo);
380 -      free(kmoji);
381 -      free(kouho);
382 +    if ( (tmp = (w_char *)malloc0(nkouho * sizeof(w_char) * LENGTHKANJI)) == NULL ) {
383 +      free0(dic);
384 +      free0(entry);
385 +      free0(ima);
386 +      free0(hindo);
387 +      free0(kmoji);
388 +      free0(kouho);
389        return(-1);
390      }
391      for(k = 0; k < nkouho; k++) {
392 @@ -3280,23 +3283,23 @@
393      if(k == -1) {
394         buf_wnn_errorno_copy((WNN_BUF_MT *)buf)
395         if (buf_wnn_errorno_eql == WNN_JSERVER_DEAD) {
396 -         free(dic);
397 -         free(entry);
398 -         free(ima);
399 -         free(hindo);
400 -         free(kmoji);
401 -         free(kouho[0]);
402 -         free(kouho);
403 +         free0(dic);
404 +         free0(entry);
405 +         free0(ima);
406 +         free0(hindo);
407 +         free0(kmoji);
408 +         free0(kouho[0]);
409 +         free0(kouho);
410           return(-1);
411         }
412      }
413 -    free(dic);
414 -    free(entry);
415 -    free(ima);
416 -    free(hindo);
417 -    free(kmoji);
418 -    free(kouho[0]);
419 -    free(kouho);
420 +    free0(dic);
421 +    free0(entry);
422 +    free0(ima);
423 +    free0(hindo);
424 +    free0(kmoji);
425 +    free0(kouho[0]);
426 +    free0(kouho);
427      return(0);
428  } /* End of optimize_in_server */
429  
430 @@ -4482,7 +4485,7 @@
431      if(--wb->ref_cnt <= 0){
432         for(wb1 = wb; wb;){
433             if((wb1 == wb) && (wb->hinsi_list != NULL)) {
434 -               free((char *)(wb->hinsi_list));
435 +               free0((char *)(wb->hinsi_list));
436                 wb->hinsi_list = NULL;
437             }
438             wb->free_next = buf->orig.free_heap;
439 @@ -4593,7 +4596,7 @@
440      wb->num_hinsi = nhinsi;
441      if(nhinsi) {
442         int hsize = abs(nhinsi) * sizeof(int);
443 -       if((wb->hinsi_list = (int *)malloc(hsize)) == NULL) return(NULL);
444 +       if((wb->hinsi_list = (int *)malloc0(hsize)) == NULL) return(NULL);
445         bcopy(hlist, wb->hinsi_list, hsize);
446      } else
447          wb->hinsi_list = NULL;
448 @@ -4660,7 +4663,7 @@
449  
450      newsize = buf->orig.bun_suu + cnt - (bun_no2 - bun_no);
451  
452 -#define Realloc(a, b) realloc((char *)(a), (unsigned)(b))
453 +#define Realloc(a, b) realloc0((char *)(a), (unsigned)(b))
454  
455      if(newsize > buf->orig.msize_bun){
456         buf->orig.bun = (WNN_BUN **)Realloc(buf->orig.bun, newsize * sizeof(WNN_BUN *));
457 @@ -5012,7 +5015,7 @@
458  }
459  
460  int
461 -wnn_cnt_free(buf)
462 +wnn_cnt_free0(buf)
463  struct wnn_buf *buf;
464  {
465      register int n;
466 @@ -5387,10 +5390,10 @@
467   *:::DOC_END
468   */
469  int
470 -jl_free(ptr)
471 +jl_free0(ptr)
472  char *ptr;
473  {
474 -    free(ptr);
475 +    free0(ptr);
476      return(0);
477  } /* End of jl_free */
478  
479 @@ -6213,22 +6216,22 @@
480                     int ii, *hlist, nhinsi = num - 1;
481                     w_char whname[64];
482                     if(nhinsi) {
483 -                       if(!(hlist = (int *)malloc(nhinsi * sizeof(int))))
484 +                       if(!(hlist = (int *)malloc0(nhinsi * sizeof(int))))
485                         goto _Err_happend;
486                         for(ii = 0; ii < nhinsi; ii++) {
487                             _Sstrcpy(whname, s[ii]);
488                             if((hlist[ii] =
489                                 jl_hinsi_number_e_body(env, whname)) == -1) {
490 -                               free((char *)hlist);
491 +                               free0((char *)hlist);
492                                 goto _Err_happend;
493                             }
494                         }
495                         if(strcmp(code, "unuse_hinsi") == 0) nhinsi *= -1;
496                         if(js_set_henkan_hinsi(env, 1, nhinsi, hlist) < 0) {
497 -                           free((char *)hlist);
498 +                           free0((char *)hlist);
499                             goto _Err_happend;
500                         }
501 -                       free((char *)hlist);
502 +                       free0((char *)hlist);
503                     }
504                 } 
505                 break;
506 @@ -6974,11 +6977,11 @@
507  
508      if(nhinsi) {
509          hsize = abs(nhinsi);
510 -        hno = (int *)malloc(hsize * sizeof(int));
511 +        hno = (int *)malloc0(hsize * sizeof(int));
512          for(i = 0; i < hsize; i++) {
513              _Sstrcpy(tmp, hname[i]);
514              if((hno[i] = jl_hinsi_number_e_body(env, tmp)) == -1) {
515 -                free((char *)hno);
516 +                free0((char *)hno);
517                  return(-1);
518              }
519          }
520 @@ -6987,10 +6990,10 @@
521      if((x = js_set_henkan_hinsi(env, mode, nhinsi, hno)) == -1) {
522          env_wnn_errorno_copy(env);
523          if_dead_disconnect(env);
524 -        if(nhinsi) free((char *)hno);
525 +        if(nhinsi) free0((char *)hno);
526          return(-1);
527      }
528 -    if(nhinsi) free((char *)hno);
529 +    if(nhinsi) free0((char *)hno);
530      return (x);
531  }
532  
533 @@ -8164,7 +8167,7 @@
534      if (!buf || !buf->bun || !(data = buf->bun[bun_no])) return(-1);
535      if (js_dic_info(buf->env, data->dic_no, &dic) < 0)
536         return(-1);
537 -    if (!(yomi = (w_char *)malloc(sizeof(w_char) * (data->yomilen + 1))))
538 +    if (!(yomi = (w_char *)malloc0(sizeof(w_char) * (data->yomilen + 1))))
539         return(-1);
540      wnn_Strncpy(yomi, data->yomi, data->yomilen);
541      yomi[data->yomilen] = (w_char)0;
542 @@ -8191,12 +8194,12 @@
543      InfoShoRec *info, *prev;
544  
545      if (max <= 0) return(NULL);
546 -    if (!(info = (InfoShoRec *)malloc(sizeof(InfoShoRec) * max))) return(NULL);
547 +    if (!(info = (InfoShoRec *)malloc0(sizeof(InfoShoRec) * max))) return(NULL);
548      bzero((char *)info, sizeof(InfoShoRec) * max);
549  
550      for (i = 0; i < max; i++) {
551         if (Sho_Info(buf, i, &info[i]) < 0) {
552 -           free((char *)info);
553 +           free0((char *)info);
554             return(NULL);
555         }
556         info[i].next = NULL;
557 @@ -8214,7 +8217,7 @@
558      InfoTotalRec *info;
559  
560      if (!p) return(NULL);
561 -    if (!(info = (InfoTotalRec *)malloc(sizeof(InfoTotalRec)))) return(NULL);
562 +    if (!(info = (InfoTotalRec *)malloc0(sizeof(InfoTotalRec)))) return(NULL);
563      bzero((char *)info, sizeof(InfoTotalRec));
564  
565      for (; p; p = p->next) {
566 @@ -8243,7 +8246,7 @@
567      }
568  
569      if (cnt <= 0) return(NULL);
570 -    if (!(info = (InfoDaiRec *)malloc(sizeof(InfoDaiRec) * cnt))) return(NULL);
571 +    if (!(info = (InfoDaiRec *)malloc0(sizeof(InfoDaiRec) * cnt))) return(NULL);
572      bzero((char *)info, sizeof(InfoDaiRec) * cnt);
573  
574      d = &info[0];
575 @@ -8585,18 +8588,18 @@
576         } */
577      if(nhinsi){
578          hsize = abs(nhinsi);
579 -        hno = (int *)malloc(hsize * sizeof(int));
580 +        hno = (int *)malloc0(hsize * sizeof(int));
581          for(i = 0; i < hsize; i++) {
582              _Sstrcpy(tmp, hname[i]);
583              if((hno[i] = jl_hinsi_number_e(buf->env, tmp)) == -1) {
584 -                free((char *)hno);
585 +                free0((char *)hno);
586                  UnlockMutex(&BUF_LOCK(buf));
587                  return(-1);
588              }
589          }
590      }
591      x = zen_conv_dai_ikeiji1(buf, bun_no, bun_no2, use_maep, uniq_level, 0, nhinsi, hno);
592 -    if(nhinsi) free((char *)hno);
593 +    if(nhinsi) free0((char *)hno);
594      UnlockMutex(&BUF_LOCK(buf));
595      return x;
596  }
597 diff -uNr Xsi.orig/Wnn/jlib/js.c Xsi/Wnn/jlib/js.c
598 --- Xsi.orig/Wnn/jlib/js.c      Wed Oct 28 13:36:31 1998
599 +++ Xsi/Wnn/jlib/js.c   Tue Nov 10 05:04:13 1998
600 @@ -160,7 +160,9 @@
601  */
602  
603  
604 -extern char    *malloc();
605 +extern char    *malloc0();
606 +extern void    free0();
607 +extern char    *realloc0();
608  
609  #include <stdio.h>
610  #include <ctype.h>
611 @@ -205,7 +207,7 @@
612  #include "../etc/pwd.c"
613  
614  
615 -char *malloc();
616 +char *malloc0();
617  
618  typedef struct _host_address {
619      int address_len;
620 @@ -439,7 +441,7 @@
621      }
622      if (!(sp = getservbyname(name,"tcp"))) return(-1);
623      len = strlen(name);
624 -    if (!(p = (my_serv_struct *)malloc(sizeof(my_serv_struct) + len + 1)))
625 +    if (!(p = (my_serv_struct *)malloc0(sizeof(my_serv_struct) + len + 1)))
626         return(-1);
627      p->name = ((char *)p) + sizeof(my_serv_struct);
628      strcpy(p->name, name);
629 @@ -894,7 +896,7 @@
630         return NULL;
631      }
632      sbp=0;     /* init sndBufPointer */
633 -    if(!(new_js=(char *)malloc(sizeof(WNN_JSERVER_ID_INT)))){
634 +    if(!(new_js=(char *)malloc0(sizeof(WNN_JSERVER_ID_INT)))){
635         js_wnn_errorno_set=WNN_ALLOC_FAIL;
636         return NULL;
637      }
638 @@ -905,7 +907,7 @@
639      server->js_dead_env_flg= 0;
640      if((current_sd= cd_open_in_by_addr(addr, addrlen, port, tmout))==-1){
641         js_wnn_errorno_set = WNN_NO_JSERVER;
642 -       free((char*)server);
643 +       free0((char*)server);
644         current_js=NULL;
645         return NULL;
646      }
647 @@ -962,7 +964,7 @@
648   }
649   UnlockMutex(&msg_lock);
650  
651 - if(!(new_js=(char *)malloc(sizeof(WNN_JSERVER_ID_INT)))){
652 + if(!(new_js=(char *)malloc0(sizeof(WNN_JSERVER_ID_INT)))){
653       wnn_errorno=WNN_ALLOC_FAIL;
654       return NULL;
655   }
656 @@ -988,7 +990,7 @@
657     strcpy(host,"unix");
658     if((current_sd= cd_open(lang))==-1){
659         UnlockMutex(&open_lock);
660 -       wnn_errorno=WNN_SOCK_OPEN_FAIL;free((char*)current_js);current_js=NULL;
661 +       wnn_errorno=WNN_SOCK_OPEN_FAIL;free0((char*)current_js);current_js=NULL;
662         return NULL;
663     }
664   }else{
665 @@ -996,7 +998,7 @@
666     host[WNN_HOSTLEN-1] = '\0'; /* truncate by WNN_HOSTLEN */
667     if((current_sd= cd_open_in(servername, lang, tmout))==-1){
668          UnlockMutex(&open_lock);
669 -       wnn_errorno=WNN_SOCK_OPEN_FAIL;free((char*)current_js);current_js=NULL;
670 +       wnn_errorno=WNN_SOCK_OPEN_FAIL;free0((char*)current_js);current_js=NULL;
671         return NULL;
672     }
673   }
674 @@ -1036,7 +1038,7 @@
675  
676   if(server==0) return(-1);
677   tmp_js_id = *(WNN_JSERVER_ID_INT *)server;
678 - free((char *)server);
679 + free0((char *)server);
680   current_js = &tmp_js_id;
681   server = (WNN_JSERVER_ID *)current_js;
682   set_current_js(server);
683 @@ -1074,7 +1076,7 @@
684      void js_set_lang();
685  
686      set_current_js(server);
687 -    if(!(env=(struct wnn_env_int *)malloc(sizeof(struct wnn_env_int)))){
688 +    if(!(env=(struct wnn_env_int *)malloc0(sizeof(struct wnn_env_int)))){
689             js_wnn_errorno_set=WNN_ALLOC_FAIL;
690             return NULL;
691      }
692 @@ -1082,14 +1084,14 @@
693      handler_of_jserver_dead(server);
694      if(js_wnn_errorno_eql) {
695          UnlockMutex(&(server_js_lock));
696 -        free(env);
697 +        free0(env);
698          return(NULL);
699      }
700      snd_head(JS_CONNECT, server);
701      putscom(env_name, server);
702      snd_flush(server);
703      e_id=get4com(server);
704 -    if(e_id==-1){ js_wnn_errorno_set= get4com(server); free(env); return NULL; }
705 +    if(e_id==-1){ js_wnn_errorno_set= get4com(server); free0(env); return NULL; }
706      UnlockMutex(&(server_js_lock));
707      env->orig.env_id = e_id;
708      env->orig.js_id  = (WNN_JSERVER_ID *)server;
709 @@ -1188,7 +1190,7 @@
710   if(env==0) return(-1);
711   /* ËÜÍè¤Ï¡¢free ¤·¤Ê¤­¤ã¤¢¤«¤ó¤Î¤À¤±¤É¡¢¥ê¥½¡¼¥¹´ÉÍý¤¬½ÐÍè¤Ê¤¤¤·¡¢
712      ¤Þ¤¢¡¢8¥Ð¥¤¥È¤À¤«¤é¡¢¥´¥ß¤¬»Ä¤ë¤±¤É¤¤¤¤¤À¤í¤¦¡£
713 - free((char *)env);
714 + free0((char *)env);
715   */
716   set_current_js(env->js_id);
717   LockMutex(&(env_js_lock));
718 @@ -1581,7 +1583,7 @@
719       UnlockMutex(&(env_js_lock)); return -1;
720   }
721   *nhinsi = get4com(env->js_id);
722 - if(((*hlist) = (int *)malloc(abs(*nhinsi) * sizeof(int))) == NULL) {
723 + if(((*hlist) = (int *)malloc0(abs(*nhinsi) * sizeof(int))) == NULL) {
724       int dummy;
725       for(i = 0; i < abs(*nhinsi); i++) dummy = get4com(env->js_id);
726       env_wnn_errorno_set = WNN_ALLOC_FAIL;
727 @@ -2839,7 +2841,7 @@
728      *curfzk = get4com(server);
729  
730      /* ¾ðÊó¼õ¤±¼è¤êÍѹ½Â¤ÂΤÎÎΰè¤ò³ÎÊݤ¹¤ë */
731 -    if(((*ret) = (WNN_FZK_INFO *)malloc((count + 1) *
732 +    if(((*ret) = (WNN_FZK_INFO *)malloc0((count + 1) *
733                                         sizeof(WNN_FZK_INFO))) == NULL) {
734         WNN_FZK_INFO dummy;
735         for(i = 0; i < count; i++){
736 @@ -3724,13 +3726,13 @@
737      if(ret->size < ret->num + fi_num) {
738         /* ¿·¤¿¤Ë£Æ£É´Ø·¸¥Ç¡¼¥¿¹½Â¤ÂÎÇÛÎó¤ò³ÎÊݤ¹¤ë */
739         fi_data = (struct fi_rel_data *)
740 -           malloc((ret->num + fi_num) * sizeof(struct fi_rel_data));
741 +           malloc0((ret->num + fi_num) * sizeof(struct fi_rel_data));
742  
743         /* ´û¤Ë»ÈÍѤ·¤Æ¤¤¤¿£Æ£É´Ø·¸¥Ç¡¼¥¿¤ò¥³¥Ô¡¼¤¹¤ë */
744         if(fi_data) {
745             if(ret->fi_buf) {
746                 bcopy(ret->fi_buf, fi_data, ret->num * sizeof(struct fi_rel_data));
747 -               free((char *)ret->fi_buf);
748 +               free0((char *)ret->fi_buf);
749             }
750         }
751         ret->fi_buf = fi_data;
752 @@ -3962,8 +3964,8 @@
753  {
754   if(ret->size < size){
755         if(ret->buf)
756 -           free((char *)ret->buf);
757 -       ret->buf = malloc(size);
758 +           free0((char *)ret->buf);
759 +       ret->buf = malloc0(size);
760         ret->size = size;
761   }
762  }
763 @@ -4263,7 +4265,7 @@
764          funiq.createhost[i]=get1com(env->js_id);
765      }
766      njisho = get1com(env->js_id);
767 -    if((primary = (int *)malloc(njisho * sizeof(int))) == NULL) {
768 +    if((primary = (int *)malloc0(njisho * sizeof(int))) == NULL) {
769         env_wnn_errorno_set = WNN_MALLOC_ERR;
770          UnlockMutex(&(env_js_lock));
771          return(-1);
772 @@ -4271,12 +4273,12 @@
773      for(i = 0; i < njisho; i++)
774          primary[i] = get4com(env->js_id);
775      if(create_fi_hindo_file(&funiq,fn,com,hpasswd,njisho,primary,NULL) == -1){
776 -       free(primary);
777 +       free0(primary);
778          env_wnn_errorno_set = WNN_FILE_CREATE_ERROR;
779          UnlockMutex(&(env_js_lock));
780          return(-1);
781      }
782 -    free(primary);
783 +    free0(primary);
784      UnlockMutex(&(env_js_lock));
785      return(0);
786  } /* End of js_fi_hindo_file_create_client */
787 @@ -4563,7 +4565,7 @@
788         num++;
789      }
790      if (num == 0) return(0);
791 -    if (!(l = (char **)(s = malloc((sizeof(char *) * num) + total)))) {
792 +    if (!(l = (char **)(s = malloc0((sizeof(char *) * num) + total)))) {
793         js_wnn_errorno_set = WNN_MALLOC_ERR;
794         return(-1);
795      }
796 @@ -4897,7 +4899,7 @@
797         UnlockMutex(&(server_js_lock));
798         return((char **)NULL);
799      }
800 -    if (!(save = p = malloc((sizeof(host_address) * total_num) + bytes))) {
801 +    if (!(save = p = malloc0((sizeof(host_address) * total_num) + bytes))) {
802         for (i = 0; i < bytes; i++) get1com(server);
803         js_wnn_errorno_set = WNN_MALLOC_ERR;
804         return((char **)NULL);
805 @@ -4931,8 +4933,8 @@
806         else
807             total += get_host_name_len(host_p);
808      }
809 -    if (!(p = malloc((sizeof(char *) * total_num) + total + total_num))) {
810 -       free((char *)save);
811 +    if (!(p = malloc0((sizeof(char *) * total_num) + total + total_num))) {
812 +       free0((char *)save);
813         js_wnn_errorno_set = WNN_MALLOC_ERR;
814         UnlockMutex(&(server_js_lock));
815         return((char **)NULL);
816 @@ -4947,7 +4949,7 @@
817         } else
818             p += get_host_name(host_p, p) + 1;
819      }
820 -    free((char *)save);
821 +    free0((char *)save);
822      *ret_num = total_num;
823      UnlockMutex(&(server_js_lock));
824      return(out_save);
825 @@ -5449,5 +5451,6 @@
826   return x;
827  }
828  /* end of js_ikeiji_with_data */
829 +#include "malloc.c"
830  
831  
832 diff -uNr Xsi.orig/Wnn/jlib/malloc.c Xsi/Wnn/jlib/malloc.c
833 --- Xsi.orig/Wnn/jlib/malloc.c  Thu Jan  1 09:00:00 1970
834 +++ Xsi/Wnn/jlib/malloc.c       Tue Nov 10 04:58:00 1998
835 @@ -0,0 +1,86 @@
836 +/*
837 + * $Id$
838 + */
839 +/*
840 + * Copyright Kyoto University Research Institute for Mathematical Sciences
841 + *                 1987, 1988, 1989, 1990, 1991
842 + * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
843 + * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
844 + *
845 + * Permission to use, copy, modify, distribute, and sell this software
846 + * and its documentation for any purpose is hereby granted without fee,
847 + * provided that all of the following conditions are satisfied:
848 + *
849 + * 1) The above copyright notices appear in all copies
850 + * 2) Both those copyright notices and this permission notice appear
851 + *    in supporting documentation
852 + * 3) The name of "Wnn" isn't changed unless substantial modifications
853 + *    are made, or
854 + * 3') Following words followed by the above copyright notices appear
855 + *    in all supporting documentation of software based on "Wnn":
856 + *
857 + *   "This software is based on the original version of Wnn developed by
858 + *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
859 + *    OMRON Corporation and ASTEC Inc."
860 + *
861 + * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
862 + *    publicity pertaining to distribution of the software without
863 + *    specific, written prior permission
864 + *
865 + * KURIMS, OMRON and ASTEC make no representations about the suitability
866 + * of this software for any purpose.  It is provided "as is" without
867 + * express or implied warranty.
868 + *
869 + * Wnn consortium is one of distributors of the official Wnn source code
870 + * release.  Wnn consortium also makes no representations about the
871 + * suitability of this software for any purpose.  It is provided "as is"
872 + * without express or implied warranty.
873 + *
874 + * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
875 + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
876 + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
877 + * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
878 + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
879 + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
880 + * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
881 + * PERFORMANCE OF THIS SOFTWARE.
882 + *
883 + */
884 +/*     Version 4.0
885 + */
886 +#include <stdio.h>
887 +/* #include "wnn_malloc.h" */
888 +
889 +char *
890 +malloc0(size)
891 +int size;
892 +{
893 +    if(size == NULL){
894 +       size = 1;
895 +    }
896 +    size = (size + 7) & 0xfffffff8;
897 +    return(calloc(size,1));
898 +}
899 +
900 +void
901 +free0(pter)
902 +char *pter;
903 +{
904 +    if(pter == NULL) return;
905 +    free(pter);
906 +    return;
907 +}
908 +
909 +char *
910 +realloc0(pter,size)
911 +char *pter;
912 +int size;
913 +{
914 +    if(size == NULL){
915 +       size = 1;
916 +    }
917 +    size = (size + 7) & 0xfffffff8;
918 +    if(pter == NULL)
919 +       return(malloc0(size));
920 +    return(realloc(pter,size));
921 +}
This page took 0.147759 seconds and 3 git commands to generate.