Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

voca_malloc.c

Go to the documentation of this file.
00001 
00017 /*
00018  * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University
00019  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00020  * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology, Nagoya Institute of Technology
00021  * All rights reserved
00022  */
00023 
00024 #include <sent/stddefs.h>
00025 #include <sent/vocabulary.h>
00026 
00027 
00033 WORD_INFO *
00034 word_info_new()
00035 {
00036   WORD_INFO *new;
00037 
00038   new = (WORD_INFO *)mymalloc(sizeof(WORD_INFO));
00039 
00040   return(new);
00041 }
00042 
00048 void
00049 word_info_free(WORD_INFO *winfo)
00050 {
00051   WORD_ID w;
00052   /* free each word info */
00053   for(w=0;w<winfo->num;w++) {
00054     free(winfo->wname[w]);
00055     free(winfo->woutput[w]);
00056     free(winfo->wseq[w]);
00057   }
00058   /* free word info */
00059   free(winfo->wname);
00060   free(winfo->woutput);
00061   free(winfo->wseq);
00062   free(winfo->wlen);
00063   free(winfo->wton);
00064 #ifdef CLASS_NGRAM
00065   free(winfo->cprob);
00066 #endif
00067   free(winfo->is_transparent);
00068   /* free whole */
00069   free(winfo);
00070 }
00071 
00077 void
00078 winfo_init(WORD_INFO *winfo)
00079 {
00080   int n;
00081   
00082   n = MAXWSTEP;
00083   winfo->wlen = (unsigned char *)mymalloc(sizeof(unsigned char)*n);
00084   winfo->wname = (char **)mymalloc(sizeof(char *)*n);
00085   winfo->woutput = (char **)mymalloc(sizeof(char *)*n);
00086   winfo->wseq = (HMM_Logical ***)mymalloc(sizeof(HMM_Logical **)*n);
00087   winfo->wton = (WORD_ID *)mymalloc(sizeof(WORD_ID)*n);
00088 #ifdef CLASS_NGRAM
00089   winfo->cprob = (LOGPROB *)mymalloc(sizeof(LOGPROB)*n);
00090   winfo->cwnum = 0;
00091 #endif
00092   winfo->is_transparent = (boolean *)mymalloc(sizeof(boolean)*n);
00093   winfo->maxnum = n;
00094   winfo->num = 0;
00095   winfo->head_silwid = winfo->tail_silwid = WORD_INVALID;
00096   winfo->maxwn = 0;
00097   winfo->maxwlen = 0;
00098   winfo->errnum = 0;
00099   winfo->errph_root = NULL;
00100 }
00101 
00107 void
00108 winfo_expand(WORD_INFO *winfo)
00109 {
00110   int n;
00111 
00112   n = winfo->maxnum;
00113   if (n >= MAX_WORD_NUM) {
00114     j_error("Error: maximum dict size exceeded limit (%d)\n", MAX_WORD_NUM);
00115   }
00116   n += MAXWSTEP;
00117   if (n > MAX_WORD_NUM) n = MAX_WORD_NUM;
00118 
00119   winfo->wlen = (unsigned char *)myrealloc(winfo->wlen, sizeof(unsigned char)*n);
00120   winfo->wname = (char **)myrealloc(winfo->wname, sizeof(char *)*n);
00121   winfo->woutput = (char **)myrealloc(winfo->woutput, sizeof(char *)*n);
00122   winfo->wseq = (HMM_Logical ***)myrealloc(winfo->wseq, sizeof(HMM_Logical **)*n);
00123   winfo->wton = (WORD_ID *)myrealloc(winfo->wton, sizeof(WORD_ID)*n);
00124 #ifdef CLASS_NGRAM
00125   winfo->cprob = (LOGPROB *)myrealloc(winfo->cprob, sizeof(LOGPROB)*n);
00126 #endif
00127   winfo->is_transparent = (boolean *)myrealloc(winfo->is_transparent, sizeof(boolean)*n);
00128   winfo->maxnum = n;
00129 }
00130 

Generated on Tue Mar 28 16:17:43 2006 for Julius by  doxygen 1.4.2