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