282 | 282 |
#if (defined(__MACH__) && defined(__APPLE__))
|
283 | 283 |
if(!resolved_path)
|
284 | 284 |
{
|
285 | |
resolved_path = malloc(PATH_MAX+1); /* fixes bug on Leopard when resolved_path == NULL */
|
|
285 |
resolved_path = (unsigned char *)malloc(PATH_MAX+1); /* fixes bug on Leopard when resolved_path == NULL */
|
286 | 286 |
}
|
287 | 287 |
#endif
|
288 | 288 |
|
|
292 | 292 |
#ifdef __MINGW32__
|
293 | 293 |
if(!resolved_path)
|
294 | 294 |
{
|
295 | |
resolved_path = malloc(PATH_MAX+1);
|
|
295 |
resolved_path = (unsigned char *)malloc(PATH_MAX+1);
|
296 | 296 |
}
|
297 | 297 |
return(_fullpath(resolved_path, path, PATH_MAX));
|
298 | 298 |
#else
|
|
316 | 316 |
{
|
317 | 317 |
(void)__off;
|
318 | 318 |
|
319 | |
unsigned char *pnt = malloc(__len);
|
|
319 |
unsigned char *pnt = (unsigned char *)malloc(__len);
|
320 | 320 |
off_t cur_offs = lseek(__fd, 0, SEEK_CUR);
|
321 | 321 |
size_t i;
|
322 | 322 |
|
|
792 | 792 |
char *valpos_handle_nam;
|
793 | 793 |
char *curval_handle_nam;
|
794 | 794 |
char *tchn_handle_nam;
|
|
795 |
|
|
796 |
fstEnumHandle max_enumhandle;
|
795 | 797 |
};
|
796 | 798 |
|
797 | 799 |
|
|
803 | 805 |
{
|
804 | 806 |
xc->fseek_failed = 1;
|
805 | 807 |
#ifdef FST_DEBUG
|
806 | |
fprintf(stderr, FST_APIMESS"Seek to #%"PRId64" (whence = %d) failed!\n", offset, whence);
|
|
808 |
fprintf(stderr, FST_APIMESS"Seek to #%" PRId64 " (whence = %d) failed!\n", offset, whence);
|
807 | 809 |
perror("Why");
|
808 | 810 |
#endif
|
809 | 811 |
}
|
|
969 | 971 |
if(!xc->valpos_mem)
|
970 | 972 |
{
|
971 | 973 |
fflush(xc->valpos_handle);
|
972 | |
xc->valpos_mem = fstMmap(NULL, xc->maxhandle * 4 * sizeof(uint32_t), PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->valpos_handle), 0);
|
|
974 |
xc->valpos_mem = (uint32_t *)fstMmap(NULL, xc->maxhandle * 4 * sizeof(uint32_t), PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->valpos_handle), 0);
|
973 | 975 |
}
|
974 | 976 |
if(!xc->curval_mem)
|
975 | 977 |
{
|
976 | 978 |
fflush(xc->curval_handle);
|
977 | |
xc->curval_mem = fstMmap(NULL, xc->maxvalpos, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->curval_handle), 0);
|
|
979 |
xc->curval_mem = (unsigned char *)fstMmap(NULL, xc->maxvalpos, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->curval_handle), 0);
|
978 | 980 |
}
|
979 | 981 |
}
|
980 | 982 |
|
|
1105 | 1107 |
*/
|
1106 | 1108 |
void *fstWriterCreate(const char *nam, int use_compressed_hier)
|
1107 | 1109 |
{
|
1108 | |
struct fstWriterContext *xc = calloc(1, sizeof(struct fstWriterContext));
|
|
1110 |
struct fstWriterContext *xc = (struct fstWriterContext *)calloc(1, sizeof(struct fstWriterContext));
|
1109 | 1111 |
|
1110 | 1112 |
xc->compress_hier = use_compressed_hier;
|
1111 | 1113 |
fstDetermineBreakSize(xc);
|
|
1119 | 1121 |
else
|
1120 | 1122 |
{
|
1121 | 1123 |
int flen = strlen(nam);
|
1122 | |
char *hf = calloc(1, flen + 6);
|
|
1124 |
char *hf = (char *)calloc(1, flen + 6);
|
1123 | 1125 |
|
1124 | 1126 |
memcpy(hf, nam, flen);
|
1125 | 1127 |
strcpy(hf + flen, ".hier");
|
|
1130 | 1132 |
xc->curval_handle = tmpfile_open(&xc->curval_handle_nam); /* .bits */
|
1131 | 1133 |
xc->tchn_handle = tmpfile_open(&xc->tchn_handle_nam); /* .tchn */
|
1132 | 1134 |
xc->vchg_alloc_siz = xc->fst_break_size + xc->fst_break_add_size;
|
1133 | |
xc->vchg_mem = malloc(xc->vchg_alloc_siz);
|
|
1135 |
xc->vchg_mem = (unsigned char *)malloc(xc->vchg_alloc_siz);
|
1134 | 1136 |
|
1135 | 1137 |
if(xc->hier_handle && xc->geom_handle && xc->valpos_handle && xc->curval_handle && xc->vchg_mem && xc->tchn_handle)
|
1136 | 1138 |
{
|
|
1179 | 1181 |
int rc;
|
1180 | 1182 |
|
1181 | 1183 |
destlen = xc->maxvalpos;
|
1182 | |
dmem = malloc(compressBound(destlen));
|
|
1184 |
dmem = (unsigned char *)malloc(compressBound(destlen));
|
1183 | 1185 |
rc = compress2(dmem, &destlen, xc->curval_mem, xc->maxvalpos, 4); /* was 9...which caused performance drag on traces with many signals */
|
1184 | 1186 |
|
1185 | 1187 |
fputc(FST_BL_SKIP, xc->handle); /* temporarily tag the section, use FST_BL_VCDATA on finalize */
|
|
1268 | 1270 |
xc->already_in_flush = 1; /* should really do this with a semaphore */
|
1269 | 1271 |
|
1270 | 1272 |
xc->section_header_only = 0;
|
1271 | |
scratchpad = malloc(xc->vchg_siz);
|
|
1273 |
scratchpad = (unsigned char *)malloc(xc->vchg_siz);
|
1272 | 1274 |
|
1273 | 1275 |
vchg_mem = xc->vchg_mem;
|
1274 | 1276 |
|
|
1278 | 1280 |
fpos = 1;
|
1279 | 1281 |
|
1280 | 1282 |
packmemlen = 1024; /* maintain a running "longest" allocation to */
|
1281 | |
packmem = malloc(packmemlen); /* prevent continual malloc...free every loop iter */
|
|
1283 |
packmem = (unsigned char *)malloc(packmemlen); /* prevent continual malloc...free every loop iter */
|
1282 | 1284 |
|
1283 | 1285 |
for(i=0;i<xc->maxhandle;i++)
|
1284 | 1286 |
{
|
|
1398 | 1400 |
idx = ((vm4ip[1]+7) & ~7);
|
1399 | 1401 |
switch(vm4ip[1] & 7)
|
1400 | 1402 |
{
|
1401 | |
case 0: do { acc = (pnt[idx+7-8] & 1) << 0;
|
1402 | |
case 7: acc |= (pnt[idx+6-8] & 1) << 1;
|
1403 | |
case 6: acc |= (pnt[idx+5-8] & 1) << 2;
|
1404 | |
case 5: acc |= (pnt[idx+4-8] & 1) << 3;
|
1405 | |
case 4: acc |= (pnt[idx+3-8] & 1) << 4;
|
1406 | |
case 3: acc |= (pnt[idx+2-8] & 1) << 5;
|
1407 | |
case 2: acc |= (pnt[idx+1-8] & 1) << 6;
|
|
1403 |
case 0: do { acc = (pnt[idx+7-8] & 1) << 0; /* fallthrough */
|
|
1404 |
case 7: acc |= (pnt[idx+6-8] & 1) << 1; /* fallthrough */
|
|
1405 |
case 6: acc |= (pnt[idx+5-8] & 1) << 2; /* fallthrough */
|
|
1406 |
case 5: acc |= (pnt[idx+4-8] & 1) << 3; /* fallthrough */
|
|
1407 |
case 4: acc |= (pnt[idx+3-8] & 1) << 4; /* fallthrough */
|
|
1408 |
case 3: acc |= (pnt[idx+2-8] & 1) << 5; /* fallthrough */
|
|
1409 |
case 2: acc |= (pnt[idx+1-8] & 1) << 6; /* fallthrough */
|
1408 | 1410 |
case 1: acc |= (pnt[idx+0-8] & 1) << 7;
|
1409 | 1411 |
*(--scratchpnt) = acc;
|
1410 | 1412 |
idx -= 8;
|
|
1440 | 1442 |
else
|
1441 | 1443 |
{
|
1442 | 1444 |
free(packmem);
|
1443 | |
dmem = packmem = malloc(compressBound(packmemlen = wrlen));
|
|
1445 |
dmem = packmem = (unsigned char *)malloc(compressBound(packmemlen = wrlen));
|
1444 | 1446 |
}
|
1445 | 1447 |
|
1446 | 1448 |
rc = compress2(dmem, &destlen, scratchpnt, wrlen, 4);
|
|
1495 | 1497 |
else
|
1496 | 1498 |
{
|
1497 | 1499 |
free(packmem);
|
1498 | |
dmem = packmem = malloc(packmemlen = (wrlen * 2) + 2);
|
|
1500 |
dmem = packmem = (unsigned char *)malloc(packmemlen = (wrlen * 2) + 2);
|
1499 | 1501 |
}
|
1500 | 1502 |
|
1501 | 1503 |
rc = (xc->fourpack) ? LZ4_compress((char *)scratchpnt, (char *)dmem, wrlen) : fastlz_compress(scratchpnt, wrlen, dmem);
|
|
1677 | 1679 |
tlen = ftello(xc->tchn_handle);
|
1678 | 1680 |
fstWriterFseeko(xc, xc->tchn_handle, 0, SEEK_SET);
|
1679 | 1681 |
|
1680 | |
tmem = fstMmap(NULL, tlen, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->tchn_handle), 0);
|
|
1682 |
tmem = (unsigned char *)fstMmap(NULL, tlen, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->tchn_handle), 0);
|
1681 | 1683 |
if(tmem)
|
1682 | 1684 |
{
|
1683 | 1685 |
unsigned long destlen = tlen;
|
1684 | |
unsigned char *dmem = malloc(compressBound(destlen));
|
|
1686 |
unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen));
|
1685 | 1687 |
int rc = compress2(dmem, &destlen, tmem, tlen, 9);
|
1686 | 1688 |
|
1687 | 1689 |
if((rc == Z_OK) && (((off_t)destlen) < tlen))
|
|
1780 | 1782 |
|
1781 | 1783 |
if(xc->parallel_enabled)
|
1782 | 1784 |
{
|
1783 | |
struct fstWriterContext *xc2 = malloc(sizeof(struct fstWriterContext));
|
|
1785 |
struct fstWriterContext *xc2 = (struct fstWriterContext *)malloc(sizeof(struct fstWriterContext));
|
1784 | 1786 |
unsigned int i;
|
1785 | 1787 |
|
1786 | 1788 |
pthread_mutex_lock(&xc->mutex);
|
|
1789 | 1791 |
xc->xc_parent = xc;
|
1790 | 1792 |
memcpy(xc2, xc, sizeof(struct fstWriterContext));
|
1791 | 1793 |
|
1792 | |
xc2->valpos_mem = malloc(xc->maxhandle * 4 * sizeof(uint32_t));
|
|
1794 |
xc2->valpos_mem = (uint32_t *)malloc(xc->maxhandle * 4 * sizeof(uint32_t));
|
1793 | 1795 |
memcpy(xc2->valpos_mem, xc->valpos_mem, xc->maxhandle * 4 * sizeof(uint32_t));
|
1794 | 1796 |
|
1795 | 1797 |
/* curval mem is updated in the thread */
|
1796 | 1798 |
#ifdef FST_REMOVE_DUPLICATE_VC
|
1797 | |
xc2->curval_mem = malloc(xc->maxvalpos);
|
|
1799 |
xc2->curval_mem = (unsigned char *)malloc(xc->maxvalpos);
|
1798 | 1800 |
memcpy(xc2->curval_mem, xc->curval_mem, xc->maxvalpos);
|
1799 | 1801 |
#endif
|
1800 | 1802 |
|
1801 | |
xc->vchg_mem = malloc(xc->vchg_alloc_siz);
|
|
1803 |
xc->vchg_mem = (unsigned char *)malloc(xc->vchg_alloc_siz);
|
1802 | 1804 |
xc->vchg_mem[0] = '!';
|
1803 | 1805 |
xc->vchg_siz = 1;
|
1804 | 1806 |
|
|
1907 | 1909 |
/* write out geom section */
|
1908 | 1910 |
fflush(xc->geom_handle);
|
1909 | 1911 |
tlen = ftello(xc->geom_handle);
|
1910 | |
tmem = fstMmap(NULL, tlen, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->geom_handle), 0);
|
|
1912 |
tmem = (unsigned char *)fstMmap(NULL, tlen, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->geom_handle), 0);
|
1911 | 1913 |
if(tmem)
|
1912 | 1914 |
{
|
1913 | 1915 |
unsigned long destlen = tlen;
|
1914 | |
unsigned char *dmem = malloc(compressBound(destlen));
|
|
1916 |
unsigned char *dmem = (unsigned char *)malloc(compressBound(destlen));
|
1915 | 1917 |
int rc = compress2(dmem, &destlen, tmem, tlen, 9);
|
1916 | 1918 |
|
1917 | 1919 |
if((rc != Z_OK) || (((off_t)destlen) > tlen))
|
|
1979 | 1981 |
int zfd;
|
1980 | 1982 |
int fourpack_duo = 0;
|
1981 | 1983 |
#ifndef __MINGW32__
|
1982 | |
char *fnam = malloc(strlen(xc->filename) + 5 + 1);
|
|
1984 |
char *fnam = (char *)malloc(strlen(xc->filename) + 5 + 1);
|
1983 | 1985 |
#endif
|
1984 | 1986 |
|
1985 | 1987 |
fixup_offs = ftello(xc->handle);
|
|
1990 | 1992 |
|
1991 | 1993 |
if(!xc->fourpack)
|
1992 | 1994 |
{
|
1993 | |
unsigned char *mem = malloc(FST_GZIO_LEN);
|
|
1995 |
unsigned char *mem = (unsigned char *)malloc(FST_GZIO_LEN);
|
1994 | 1996 |
zfd = dup(fileno(xc->handle));
|
1995 | 1997 |
fflush(xc->handle);
|
1996 | 1998 |
zhandle = gzdopen(zfd, "wb4");
|
|
2021 | 2023 |
fflush(xc->handle);
|
2022 | 2024 |
|
2023 | 2025 |
lz4_maxlen = LZ4_compressBound(xc->hier_file_len);
|
2024 | |
mem = malloc(lz4_maxlen);
|
2025 | |
hmem = fstMmap(NULL, xc->hier_file_len, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->hier_handle), 0);
|
|
2026 |
mem = (unsigned char *)malloc(lz4_maxlen);
|
|
2027 |
hmem = (unsigned char *)fstMmap(NULL, xc->hier_file_len, PROT_READ|PROT_WRITE, MAP_SHARED, fileno(xc->hier_handle), 0);
|
2026 | 2028 |
packed_len = LZ4_compress((char *)hmem, (char *)mem, xc->hier_file_len);
|
2027 | 2029 |
fstMunmap(hmem, xc->hier_file_len);
|
2028 | 2030 |
|
|
2035 | 2037 |
int packed_len_duo;
|
2036 | 2038 |
|
2037 | 2039 |
lz4_maxlen_duo = LZ4_compressBound(packed_len);
|
2038 | |
mem_duo = malloc(lz4_maxlen_duo);
|
|
2040 |
mem_duo = (unsigned char *)malloc(lz4_maxlen_duo);
|
2039 | 2041 |
packed_len_duo = LZ4_compress((char *)mem, (char *)mem_duo, packed_len);
|
2040 | 2042 |
|
2041 | 2043 |
fstWriterVarint(xc->handle, packed_len); /* 1st round compressed length */
|
|
2095 | 2097 |
FILE *fp;
|
2096 | 2098 |
off_t offpnt, uclen;
|
2097 | 2099 |
int flen = strlen(xc->filename);
|
2098 | |
char *hf = calloc(1, flen + 5);
|
|
2100 |
char *hf = (char *)calloc(1, flen + 5);
|
2099 | 2101 |
|
2100 | 2102 |
strcpy(hf, xc->filename);
|
2101 | 2103 |
strcpy(hf+flen, ".pak");
|
|
2103 | 2105 |
|
2104 | 2106 |
if(fp)
|
2105 | 2107 |
{
|
2106 | |
void *dsth;
|
|
2108 |
gzFile dsth;
|
2107 | 2109 |
int zfd;
|
2108 | 2110 |
char gz_membuf[FST_GZIO_LEN];
|
2109 | 2111 |
|
|
2302 | 2304 |
const unsigned char *path2 = (const unsigned char *)path;
|
2303 | 2305 |
PPvoid_t pv;
|
2304 | 2306 |
#else
|
2305 | |
char *path2 = alloca(slen + 1); /* judy lacks const qualifier in its JudyHSIns definition */
|
|
2307 |
char *path2 = (char *)alloca(slen + 1); /* judy lacks const qualifier in its JudyHSIns definition */
|
2306 | 2308 |
PPvoid_t pv;
|
2307 | 2309 |
strcpy(path2, path);
|
2308 | 2310 |
#endif
|
|
2585 | 2587 |
xc->vchg_alloc_siz = xc->fst_break_size + xc->fst_break_add_size;
|
2586 | 2588 |
if(xc->vchg_mem)
|
2587 | 2589 |
{
|
2588 | |
xc->vchg_mem = realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
|
2590 |
xc->vchg_mem = (unsigned char *)realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
2589 | 2591 |
}
|
2590 | 2592 |
}
|
2591 | 2593 |
}
|
|
2723 | 2725 |
}
|
2724 | 2726 |
|
2725 | 2727 |
|
|
2728 |
fstEnumHandle fstWriterCreateEnumTable(void *ctx, const char *name, uint32_t elem_count, unsigned int min_valbits, const char **literal_arr, const char **val_arr)
|
|
2729 |
{
|
|
2730 |
fstEnumHandle handle = 0;
|
|
2731 |
unsigned int *literal_lens = NULL;
|
|
2732 |
unsigned int *val_lens = NULL;
|
|
2733 |
int lit_len_tot = 0;
|
|
2734 |
int val_len_tot = 0;
|
|
2735 |
int name_len;
|
|
2736 |
char elem_count_buf[16];
|
|
2737 |
int elem_count_len;
|
|
2738 |
int total_len;
|
|
2739 |
int pos = 0;
|
|
2740 |
char *attr_str = NULL;
|
|
2741 |
|
|
2742 |
if(ctx && name && literal_arr && val_arr && (elem_count != 0))
|
|
2743 |
{
|
|
2744 |
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
|
|
2745 |
|
|
2746 |
uint32_t i;
|
|
2747 |
|
|
2748 |
name_len = strlen(name);
|
|
2749 |
elem_count_len = sprintf(elem_count_buf, "%" PRIu32, elem_count);
|
|
2750 |
|
|
2751 |
literal_lens = (unsigned int *)calloc(elem_count, sizeof(unsigned int));
|
|
2752 |
val_lens = (unsigned int *)calloc(elem_count, sizeof(unsigned int));
|
|
2753 |
|
|
2754 |
for(i=0;i<elem_count;i++)
|
|
2755 |
{
|
|
2756 |
literal_lens[i] = strlen(literal_arr[i]);
|
|
2757 |
lit_len_tot += fstUtilityBinToEscConvertedLen((unsigned char*)literal_arr[i], literal_lens[i]);
|
|
2758 |
|
|
2759 |
val_lens[i] = strlen(val_arr[i]);
|
|
2760 |
val_len_tot += fstUtilityBinToEscConvertedLen((unsigned char*)val_arr[i], val_lens[i]);
|
|
2761 |
|
|
2762 |
if(min_valbits > 0)
|
|
2763 |
{
|
|
2764 |
if(val_lens[i] < min_valbits)
|
|
2765 |
{
|
|
2766 |
val_len_tot += (min_valbits - val_lens[i]); /* additional converted len is same for '0' character */
|
|
2767 |
}
|
|
2768 |
}
|
|
2769 |
}
|
|
2770 |
|
|
2771 |
total_len = name_len + 1 + elem_count_len + 1 + lit_len_tot + elem_count + val_len_tot + elem_count;
|
|
2772 |
|
|
2773 |
attr_str = (char*)malloc(total_len);
|
|
2774 |
pos = 0;
|
|
2775 |
|
|
2776 |
memcpy(attr_str+pos, name, name_len);
|
|
2777 |
pos += name_len;
|
|
2778 |
attr_str[pos++] = ' ';
|
|
2779 |
|
|
2780 |
memcpy(attr_str+pos, elem_count_buf, elem_count_len);
|
|
2781 |
pos += elem_count_len;
|
|
2782 |
attr_str[pos++] = ' ';
|
|
2783 |
|
|
2784 |
for(i=0;i<elem_count;i++)
|
|
2785 |
{
|
|
2786 |
pos += fstUtilityBinToEsc((unsigned char*)attr_str+pos, (unsigned char*)literal_arr[i], literal_lens[i]);
|
|
2787 |
attr_str[pos++] = ' ';
|
|
2788 |
}
|
|
2789 |
|
|
2790 |
for(i=0;i<elem_count;i++)
|
|
2791 |
{
|
|
2792 |
if(min_valbits > 0)
|
|
2793 |
{
|
|
2794 |
if(val_lens[i] < min_valbits)
|
|
2795 |
{
|
|
2796 |
memset(attr_str+pos, '0', min_valbits - val_lens[i]);
|
|
2797 |
pos += (min_valbits - val_lens[i]);
|
|
2798 |
}
|
|
2799 |
}
|
|
2800 |
|
|
2801 |
pos += fstUtilityBinToEsc((unsigned char*)attr_str+pos, (unsigned char*)val_arr[i], val_lens[i]);
|
|
2802 |
attr_str[pos++] = ' ';
|
|
2803 |
}
|
|
2804 |
|
|
2805 |
attr_str[pos-1] = 0;
|
|
2806 |
|
|
2807 |
#ifdef FST_DEBUG
|
|
2808 |
fprintf(stderr, FST_APIMESS"fstWriterCreateEnumTable() total_len: %d, pos: %d\n", total_len, pos);
|
|
2809 |
fprintf(stderr, FST_APIMESS"*%s*\n", attr_str);
|
|
2810 |
#endif
|
|
2811 |
|
|
2812 |
fstWriterSetAttrBegin(xc, FST_AT_MISC, FST_MT_ENUMTABLE, attr_str, handle = ++xc->max_enumhandle);
|
|
2813 |
|
|
2814 |
free(attr_str);
|
|
2815 |
free(val_lens);
|
|
2816 |
free(literal_lens);
|
|
2817 |
}
|
|
2818 |
|
|
2819 |
return(handle);
|
|
2820 |
}
|
|
2821 |
|
|
2822 |
|
|
2823 |
void fstWriterEmitEnumTableRef(void *ctx, fstEnumHandle handle)
|
|
2824 |
{
|
|
2825 |
struct fstWriterContext *xc = (struct fstWriterContext *)ctx;
|
|
2826 |
if(xc && handle)
|
|
2827 |
{
|
|
2828 |
fstWriterSetAttrBegin(xc, FST_AT_MISC, FST_MT_ENUMTABLE, NULL, handle);
|
|
2829 |
}
|
|
2830 |
}
|
|
2831 |
|
|
2832 |
|
2726 | 2833 |
/*
|
2727 | 2834 |
* value and time change emission
|
2728 | 2835 |
*/
|
|
2757 | 2864 |
if((fpos + len + 10) > xc->vchg_alloc_siz)
|
2758 | 2865 |
{
|
2759 | 2866 |
xc->vchg_alloc_siz += (xc->fst_break_add_size + len); /* +len added in the case of extremely long vectors and small break add sizes */
|
2760 | |
xc->vchg_mem = realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
|
2867 |
xc->vchg_mem = (unsigned char *)realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
2761 | 2868 |
if(!xc->vchg_mem)
|
2762 | 2869 |
{
|
2763 | 2870 |
fprintf(stderr, FST_APIMESS"Could not realloc() in fstWriterEmitValueChange, exiting.\n");
|
|
2871 | 2978 |
if((fpos + len + 10 + 5) > xc->vchg_alloc_siz)
|
2872 | 2979 |
{
|
2873 | 2980 |
xc->vchg_alloc_siz += (xc->fst_break_add_size + len + 5); /* +len added in the case of extremely long vectors and small break add sizes */
|
2874 | |
xc->vchg_mem = realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
|
2981 |
xc->vchg_mem = (unsigned char *)realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
2875 | 2982 |
if(!xc->vchg_mem)
|
2876 | 2983 |
{
|
2877 | 2984 |
fprintf(stderr, FST_APIMESS"Could not realloc() in fstWriterEmitVariableLengthValueChange, exiting.\n");
|
|
2948 | 3055 |
|
2949 | 3056 |
if(xc)
|
2950 | 3057 |
{
|
2951 | |
struct fstBlackoutChain *b = calloc(1, sizeof(struct fstBlackoutChain));
|
|
3058 |
struct fstBlackoutChain *b = (struct fstBlackoutChain *)calloc(1, sizeof(struct fstBlackoutChain));
|
2952 | 3059 |
|
2953 | 3060 |
b->tim = xc->curtime;
|
2954 | 3061 |
b->active = (enable != 0);
|
|
3119 | 3226 |
{
|
3120 | 3227 |
xc->fseek_failed = 1;
|
3121 | 3228 |
#ifdef FST_DEBUG
|
3122 | |
fprintf(stderr, FST_APIMESS"Seek to #%"PRId64" (whence = %d) failed!\n", offset, whence);
|
|
3229 |
fprintf(stderr, FST_APIMESS"Seek to #%" PRId64 " (whence = %d) failed!\n", offset, whence);
|
3123 | 3230 |
perror("Why");
|
3124 | 3231 |
#endif
|
3125 | 3232 |
}
|
|
3247 | 3354 |
struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
|
3248 | 3355 |
if(xc)
|
3249 | 3356 |
{
|
3250 | |
struct fstCurrHier *ch = malloc(sizeof(struct fstCurrHier));
|
|
3357 |
struct fstCurrHier *ch = (struct fstCurrHier *)malloc(sizeof(struct fstCurrHier));
|
3251 | 3358 |
int chl = xc->curr_hier ? xc->curr_hier->len : 0;
|
3252 | 3359 |
int len = chl + 1 + strlen(nam);
|
3253 | 3360 |
if(len >= xc->flat_hier_alloc_len)
|
3254 | 3361 |
{
|
3255 | |
xc->curr_flat_hier_nam = xc->curr_flat_hier_nam ? realloc(xc->curr_flat_hier_nam, len+1) : malloc(len+1);
|
|
3362 |
xc->curr_flat_hier_nam = xc->curr_flat_hier_nam ? (char *)realloc(xc->curr_flat_hier_nam, len+1) : (char *)malloc(len+1);
|
3256 | 3363 |
}
|
3257 | 3364 |
|
3258 | 3365 |
if(chl)
|
|
3472 | 3579 |
int fstReaderGetFileType(void *ctx)
|
3473 | 3580 |
{
|
3474 | 3581 |
struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
|
3475 | |
return(xc ? xc->filetype : FST_FT_VERILOG);
|
|
3582 |
return(xc ? (int)xc->filetype : (int)FST_FT_VERILOG);
|
3476 | 3583 |
}
|
3477 | 3584 |
|
3478 | 3585 |
|
|
3605 | 3712 |
if(!xc->fh)
|
3606 | 3713 |
{
|
3607 | 3714 |
off_t offs_cache = ftello(xc->f);
|
3608 | |
char *fnam = malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
|
3609 | |
unsigned char *mem = malloc(FST_GZIO_LEN);
|
|
3715 |
char *fnam = (char *)malloc(strlen(xc->filename) + 6 + 16 + 32 + 1);
|
|
3716 |
unsigned char *mem = (unsigned char *)malloc(FST_GZIO_LEN);
|
3610 | 3717 |
off_t hl, uclen;
|
3611 | 3718 |
off_t clen = 0;
|
3612 | 3719 |
gzFile zhandle = NULL;
|
|
3703 | 3810 |
else
|
3704 | 3811 |
if(htyp == FST_BL_HIER_LZ4DUO)
|
3705 | 3812 |
{
|
3706 | |
unsigned char *lz4_cmem = malloc(clen);
|
3707 | |
unsigned char *lz4_ucmem = malloc(uclen);
|
|
3813 |
unsigned char *lz4_cmem = (unsigned char *)malloc(clen);
|
|
3814 |
unsigned char *lz4_ucmem = (unsigned char *)malloc(uclen);
|
3708 | 3815 |
unsigned char *lz4_ucmem2;
|
3709 | 3816 |
uint64_t uclen2;
|
3710 | 3817 |
int skiplen2 = 0;
|
|
3712 | 3819 |
fstFread(lz4_cmem, clen, 1, xc->f);
|
3713 | 3820 |
|
3714 | 3821 |
uclen2 = fstGetVarint64(lz4_cmem, &skiplen2);
|
3715 | |
lz4_ucmem2 = malloc(uclen2);
|
|
3822 |
lz4_ucmem2 = (unsigned char *)malloc(uclen2);
|
3716 | 3823 |
pass_status = (uclen2 == (uint64_t)LZ4_decompress_safe_partial ((char *)lz4_cmem + skiplen2, (char *)lz4_ucmem2, clen - skiplen2, uclen2, uclen2));
|
3717 | 3824 |
if(pass_status)
|
3718 | 3825 |
{
|
|
3731 | 3838 |
else
|
3732 | 3839 |
if(htyp == FST_BL_HIER_LZ4)
|
3733 | 3840 |
{
|
3734 | |
unsigned char *lz4_cmem = malloc(clen);
|
3735 | |
unsigned char *lz4_ucmem = malloc(uclen);
|
|
3841 |
unsigned char *lz4_cmem = (unsigned char *)malloc(clen);
|
|
3842 |
unsigned char *lz4_ucmem = (unsigned char *)malloc(uclen);
|
3736 | 3843 |
|
3737 | 3844 |
fstFread(lz4_cmem, clen, 1, xc->f);
|
3738 | 3845 |
pass_status = (uclen == LZ4_decompress_safe_partial ((char *)lz4_cmem, (char *)lz4_ucmem, clen, uclen, uclen));
|
|
3969 | 4076 |
}
|
3970 | 4077 |
}
|
3971 | 4078 |
|
3972 | |
str = malloc(FST_ID_NAM_ATTR_SIZ+1);
|
|
4079 |
str = (char *)malloc(FST_ID_NAM_ATTR_SIZ+1);
|
3973 | 4080 |
|
3974 | 4081 |
if(fv)
|
3975 | 4082 |
{
|
|
3978 | 4085 |
|
3979 | 4086 |
fprintf(fv, "$date\n\t%s\n$end\n", xc->date);
|
3980 | 4087 |
fprintf(fv, "$version\n\t%s\n$end\n", xc->version);
|
3981 | |
if(xc->timezero) fprintf(fv, "$timezero\n\t%"PRId64"\n$end\n", xc->timezero);
|
|
4088 |
if(xc->timezero) fprintf(fv, "$timezero\n\t%" PRId64 "\n$end\n", xc->timezero);
|
3982 | 4089 |
|
3983 | 4090 |
switch(xc->timescale)
|
3984 | 4091 |
{
|
3985 | 4092 |
case 2: time_scale = 100; time_dimension[0] = 0; break;
|
3986 | |
case 1: time_scale = 10;
|
|
4093 |
case 1: time_scale = 10; /* fallthrough */
|
3987 | 4094 |
case 0: time_dimension[0] = 0; break;
|
3988 | 4095 |
|
3989 | 4096 |
case -1: time_scale = 100; time_dimension[0] = 'm'; break;
|
3990 | |
case -2: time_scale = 10;
|
|
4097 |
case -2: time_scale = 10; /* fallthrough */
|
3991 | 4098 |
case -3: time_dimension[0] = 'm'; break;
|
3992 | 4099 |
|
3993 | 4100 |
case -4: time_scale = 100; time_dimension[0] = 'u'; break;
|
3994 | |
case -5: time_scale = 10;
|
|
4101 |
case -5: time_scale = 10; /* fallthrough */
|
3995 | 4102 |
case -6: time_dimension[0] = 'u'; break;
|
3996 | 4103 |
|
3997 | 4104 |
case -10: time_scale = 100; time_dimension[0] = 'p'; break;
|
3998 | |
case -11: time_scale = 10;
|
|
4105 |
case -11: time_scale = 10; /* fallthrough */
|
3999 | 4106 |
case -12: time_dimension[0] = 'p'; break;
|
4000 | 4107 |
|
4001 | 4108 |
case -13: time_scale = 100; time_dimension[0] = 'f'; break;
|
4002 | |
case -14: time_scale = 10;
|
|
4109 |
case -14: time_scale = 10; /* fallthrough */
|
4003 | 4110 |
case -15: time_dimension[0] = 'f'; break;
|
4004 | 4111 |
|
4005 | 4112 |
case -16: time_scale = 100; time_dimension[0] = 'a'; break;
|
4006 | |
case -17: time_scale = 10;
|
|
4113 |
case -17: time_scale = 10; /* fallthrough */
|
4007 | 4114 |
case -18: time_dimension[0] = 'a'; break;
|
4008 | 4115 |
|
4009 | 4116 |
case -19: time_scale = 100; time_dimension[0] = 'z'; break;
|
4010 | |
case -20: time_scale = 10;
|
|
4117 |
case -20: time_scale = 10; /* fallthrough */
|
4011 | 4118 |
case -21: time_dimension[0] = 'z'; break;
|
4012 | 4119 |
|
4013 | 4120 |
case -7: time_scale = 100; time_dimension[0] = 'n'; break;
|
4014 | |
case -8: time_scale = 10;
|
|
4121 |
case -8: time_scale = 10; /* fallthrough */
|
4015 | 4122 |
case -9:
|
4016 | 4123 |
default: time_dimension[0] = 'n'; break;
|
4017 | 4124 |
}
|
|
4023 | 4130 |
xc->num_alias = 0;
|
4024 | 4131 |
|
4025 | 4132 |
free(xc->signal_lens);
|
4026 | |
xc->signal_lens = malloc(num_signal_dyn*sizeof(uint32_t));
|
|
4133 |
xc->signal_lens = (uint32_t *)malloc(num_signal_dyn*sizeof(uint32_t));
|
4027 | 4134 |
|
4028 | 4135 |
free(xc->signal_typs);
|
4029 | |
xc->signal_typs = malloc(num_signal_dyn*sizeof(unsigned char));
|
|
4136 |
xc->signal_typs = (unsigned char *)malloc(num_signal_dyn*sizeof(unsigned char));
|
4030 | 4137 |
|
4031 | 4138 |
fstReaderFseeko(xc, xc->fh, 0, SEEK_SET);
|
4032 | 4139 |
while(!feof(xc->fh))
|
|
4071 | 4178 |
switch(attrtype)
|
4072 | 4179 |
{
|
4073 | 4180 |
case FST_AT_ARRAY: if((subtype < FST_AR_NONE) || (subtype > FST_AR_MAX)) subtype = FST_AR_NONE;
|
4074 | |
fprintf(fv, "$attrbegin %s %s %s %"PRId64" $end\n", attrtypes[attrtype], arraytypes[subtype], str, attrarg);
|
|
4181 |
fprintf(fv, "$attrbegin %s %s %s %" PRId64 " $end\n", attrtypes[attrtype], arraytypes[subtype], str, attrarg);
|
4075 | 4182 |
break;
|
4076 | 4183 |
case FST_AT_ENUM: if((subtype < FST_EV_SV_INTEGER) || (subtype > FST_EV_MAX)) subtype = FST_EV_SV_INTEGER;
|
4077 | |
fprintf(fv, "$attrbegin %s %s %s %"PRId64" $end\n", attrtypes[attrtype], enumvaluetypes[subtype], str, attrarg);
|
|
4184 |
fprintf(fv, "$attrbegin %s %s %s %" PRId64 " $end\n", attrtypes[attrtype], enumvaluetypes[subtype], str, attrarg);
|
4078 | 4185 |
break;
|
4079 | 4186 |
case FST_AT_PACK: if((subtype < FST_PT_NONE) || (subtype > FST_PT_MAX)) subtype = FST_PT_NONE;
|
4080 | |
fprintf(fv, "$attrbegin %s %s %s %"PRId64" $end\n", attrtypes[attrtype], packtypes[subtype], str, attrarg);
|
|
4187 |
fprintf(fv, "$attrbegin %s %s %s %" PRId64 " $end\n", attrtypes[attrtype], packtypes[subtype], str, attrarg);
|
4081 | 4188 |
break;
|
4082 | 4189 |
case FST_AT_MISC:
|
4083 | 4190 |
default: attrtype = FST_AT_MISC;
|
|
4092 | 4199 |
int sidx_skiplen_dummy = 0;
|
4093 | 4200 |
uint64_t sidx = fstGetVarint64((unsigned char *)str, &sidx_skiplen_dummy);
|
4094 | 4201 |
|
4095 | |
fprintf(fv, "$attrbegin %s %02x %"PRId64" %"PRId64" $end\n", attrtypes[attrtype], subtype, sidx, attrarg);
|
|
4202 |
fprintf(fv, "$attrbegin %s %02x %" PRId64 " %" PRId64 " $end\n", attrtypes[attrtype], subtype, sidx, attrarg);
|
4096 | 4203 |
}
|
4097 | 4204 |
else
|
4098 | 4205 |
{
|
4099 | |
fprintf(fv, "$attrbegin %s %02x %s %"PRId64" $end\n", attrtypes[attrtype], subtype, str, attrarg);
|
|
4206 |
fprintf(fv, "$attrbegin %s %02x %s %" PRId64 " $end\n", attrtypes[attrtype], subtype, str, attrarg);
|
4100 | 4207 |
}
|
4101 | 4208 |
}
|
4102 | 4209 |
break;
|
|
4154 | 4261 |
if(xc->maxhandle == num_signal_dyn)
|
4155 | 4262 |
{
|
4156 | 4263 |
num_signal_dyn *= 2;
|
4157 | |
xc->signal_lens = realloc(xc->signal_lens, num_signal_dyn*sizeof(uint32_t));
|
4158 | |
xc->signal_typs = realloc(xc->signal_typs, num_signal_dyn*sizeof(unsigned char));
|
|
4264 |
xc->signal_lens = (uint32_t *)realloc(xc->signal_lens, num_signal_dyn*sizeof(uint32_t));
|
|
4265 |
xc->signal_typs = (unsigned char *)realloc(xc->signal_typs, num_signal_dyn*sizeof(unsigned char));
|
4159 | 4266 |
}
|
4160 | 4267 |
xc->signal_lens[xc->maxhandle] = len;
|
4161 | 4268 |
xc->signal_typs[xc->maxhandle] = vartype;
|
|
4176 | 4283 |
char vcdid_buf[16];
|
4177 | 4284 |
uint32_t modlen = (vartype != FST_VT_VCD_PORT) ? len : ((len - 2) / 3);
|
4178 | 4285 |
fstVcdID(vcdid_buf, xc->maxhandle+1);
|
4179 | |
fprintf(fv, "$var %s %"PRIu32" %s %s $end\n", vartypes[vartype], modlen, vcdid_buf, str);
|
|
4286 |
fprintf(fv, "$var %s %" PRIu32 " %s %s $end\n", vartypes[vartype], modlen, vcdid_buf, str);
|
4180 | 4287 |
}
|
4181 | 4288 |
xc->maxhandle++;
|
4182 | 4289 |
}
|
|
4192 | 4299 |
char vcdid_buf[16];
|
4193 | 4300 |
uint32_t modlen = (vartype != FST_VT_VCD_PORT) ? len : ((len - 2) / 3);
|
4194 | 4301 |
fstVcdID(vcdid_buf, alias);
|
4195 | |
fprintf(fv, "$var %s %"PRIu32" %s %s $end\n", vartypes[vartype], modlen, vcdid_buf, str);
|
|
4302 |
fprintf(fv, "$var %s %" PRIu32 " %s %s $end\n", vartypes[vartype], modlen, vcdid_buf, str);
|
4196 | 4303 |
}
|
4197 | 4304 |
xc->num_alias++;
|
4198 | 4305 |
}
|
|
4207 | 4314 |
|
4208 | 4315 |
maxhandle_scanbuild = xc->maxhandle ? xc->maxhandle : 1; /*scan-build warning suppression, in reality we have at least one signal */
|
4209 | 4316 |
|
4210 | |
xc->signal_lens = realloc(xc->signal_lens, maxhandle_scanbuild*sizeof(uint32_t));
|
4211 | |
xc->signal_typs = realloc(xc->signal_typs, maxhandle_scanbuild*sizeof(unsigned char));
|
|
4317 |
xc->signal_lens = (uint32_t *)realloc(xc->signal_lens, maxhandle_scanbuild*sizeof(uint32_t));
|
|
4318 |
xc->signal_typs = (unsigned char *)realloc(xc->signal_typs, maxhandle_scanbuild*sizeof(unsigned char));
|
4212 | 4319 |
|
4213 | 4320 |
free(xc->process_mask);
|
4214 | |
xc->process_mask = calloc(1, (maxhandle_scanbuild+7)/8);
|
|
4321 |
xc->process_mask = (unsigned char *)calloc(1, (maxhandle_scanbuild+7)/8);
|
4215 | 4322 |
|
4216 | 4323 |
free(xc->temp_signal_value_buf);
|
4217 | |
xc->temp_signal_value_buf = malloc(xc->longest_signal_value_len + 1);
|
|
4324 |
xc->temp_signal_value_buf = (unsigned char *)malloc(xc->longest_signal_value_len + 1);
|
4218 | 4325 |
|
4219 | 4326 |
xc->var_count = xc->maxhandle + xc->num_alias;
|
4220 | 4327 |
|
|
4243 | 4350 |
FILE *fcomp;
|
4244 | 4351 |
off_t offpnt, uclen;
|
4245 | 4352 |
char gz_membuf[FST_GZIO_LEN];
|
4246 | |
void *zhandle;
|
|
4353 |
gzFile zhandle;
|
4247 | 4354 |
int zfd;
|
4248 | 4355 |
int flen = strlen(xc->filename);
|
4249 | 4356 |
char *hf;
|
|
4253 | 4360 |
|
4254 | 4361 |
if(!seclen) return(0); /* not finished compressing, this is a failed read */
|
4255 | 4362 |
|
4256 | |
hf = calloc(1, flen + 16 + 32 + 1);
|
|
4363 |
hf = (char *)calloc(1, flen + 16 + 32 + 1);
|
4257 | 4364 |
|
4258 | 4365 |
sprintf(hf, "%s.upk_%d_%p", xc->filename, getpid(), (void *)xc);
|
4259 | 4366 |
fcomp = fopen(hf, "w+b");
|
|
4416 | 4523 |
{
|
4417 | 4524 |
uint64_t clen = seclen - 24;
|
4418 | 4525 |
uint64_t uclen = fstReaderUint64(xc->f);
|
4419 | |
unsigned char *ucdata = malloc(uclen);
|
|
4526 |
unsigned char *ucdata = (unsigned char *)malloc(uclen);
|
4420 | 4527 |
unsigned char *pnt = ucdata;
|
4421 | 4528 |
unsigned int i;
|
4422 | 4529 |
|
|
4425 | 4532 |
xc->longest_signal_value_len = 32; /* arbitrarily set at 32...this is much longer than an expanded double */
|
4426 | 4533 |
|
4427 | 4534 |
free(xc->process_mask);
|
4428 | |
xc->process_mask = calloc(1, (xc->maxhandle+7)/8);
|
|
4535 |
xc->process_mask = (unsigned char *)calloc(1, (xc->maxhandle+7)/8);
|
4429 | 4536 |
|
4430 | 4537 |
if(clen != uclen)
|
4431 | 4538 |
{
|
4432 | |
unsigned char *cdata = malloc(clen);
|
|
4539 |
unsigned char *cdata = (unsigned char *)malloc(clen);
|
4433 | 4540 |
unsigned long destlen = uclen;
|
4434 | 4541 |
unsigned long sourcelen = clen;
|
4435 | 4542 |
int rc;
|
|
4451 | 4558 |
}
|
4452 | 4559 |
|
4453 | 4560 |
free(xc->signal_lens);
|
4454 | |
xc->signal_lens = malloc(sizeof(uint32_t) * xc->maxhandle);
|
|
4561 |
xc->signal_lens = (uint32_t *)malloc(sizeof(uint32_t) * xc->maxhandle);
|
4455 | 4562 |
free(xc->signal_typs);
|
4456 | |
xc->signal_typs = malloc(sizeof(unsigned char) * xc->maxhandle);
|
|
4563 |
xc->signal_typs = (unsigned char *)malloc(sizeof(unsigned char) * xc->maxhandle);
|
4457 | 4564 |
|
4458 | 4565 |
for(i=0;i<xc->maxhandle;i++)
|
4459 | 4566 |
{
|
|
4480 | 4587 |
}
|
4481 | 4588 |
|
4482 | 4589 |
free(xc->temp_signal_value_buf);
|
4483 | |
xc->temp_signal_value_buf = malloc(xc->longest_signal_value_len + 1);
|
|
4590 |
xc->temp_signal_value_buf = (unsigned char *)malloc(xc->longest_signal_value_len + 1);
|
4484 | 4591 |
|
4485 | 4592 |
free(ucdata);
|
4486 | 4593 |
}
|
|
4509 | 4616 |
|
4510 | 4617 |
xc->num_blackouts = fstReaderVarint32(xc->f);
|
4511 | 4618 |
free(xc->blackout_times);
|
4512 | |
xc->blackout_times = calloc(xc->num_blackouts, sizeof(uint64_t));
|
|
4619 |
xc->blackout_times = (uint64_t *)calloc(xc->num_blackouts, sizeof(uint64_t));
|
4513 | 4620 |
free(xc->blackout_activity);
|
4514 | |
xc->blackout_activity = calloc(xc->num_blackouts, sizeof(unsigned char));
|
|
4621 |
xc->blackout_activity = (unsigned char *)calloc(xc->num_blackouts, sizeof(unsigned char));
|
4515 | 4622 |
|
4516 | 4623 |
for(i=0;i<xc->num_blackouts;i++)
|
4517 | 4624 |
{
|
|
4546 | 4653 |
|
4547 | 4654 |
void *fstReaderOpenForUtilitiesOnly(void)
|
4548 | 4655 |
{
|
4549 | |
struct fstReaderContext *xc = calloc(1, sizeof(struct fstReaderContext));
|
|
4656 |
struct fstReaderContext *xc = (struct fstReaderContext *)calloc(1, sizeof(struct fstReaderContext));
|
4550 | 4657 |
|
4551 | 4658 |
return(xc);
|
4552 | 4659 |
}
|
|
4554 | 4661 |
|
4555 | 4662 |
void *fstReaderOpen(const char *nam)
|
4556 | 4663 |
{
|
4557 | |
struct fstReaderContext *xc = calloc(1, sizeof(struct fstReaderContext));
|
|
4664 |
struct fstReaderContext *xc = (struct fstReaderContext *)calloc(1, sizeof(struct fstReaderContext));
|
4558 | 4665 |
|
4559 | 4666 |
if((!nam)||(!(xc->f=fopen(nam, "rb"))))
|
4560 | 4667 |
{
|
|
4564 | 4671 |
else
|
4565 | 4672 |
{
|
4566 | 4673 |
int flen = strlen(nam);
|
4567 | |
char *hf = calloc(1, flen + 6);
|
|
4674 |
char *hf = (char *)calloc(1, flen + 6);
|
4568 | 4675 |
int rc;
|
4569 | 4676 |
|
4570 | 4677 |
#if defined(__MINGW32__) || defined(FST_MACOSX)
|
|
4703 | 4810 |
|
4704 | 4811 |
if(!xc) return(0);
|
4705 | 4812 |
|
4706 | |
scatterptr = calloc(xc->maxhandle, sizeof(uint32_t));
|
4707 | |
headptr = calloc(xc->maxhandle, sizeof(uint32_t));
|
4708 | |
length_remaining = calloc(xc->maxhandle, sizeof(uint32_t));
|
|
4813 |
scatterptr = (uint32_t *)calloc(xc->maxhandle, sizeof(uint32_t));
|
|
4814 |
headptr = (uint32_t *)calloc(xc->maxhandle, sizeof(uint32_t));
|
|
4815 |
length_remaining = (uint32_t *)calloc(xc->maxhandle, sizeof(uint32_t));
|
4709 | 4816 |
|
4710 | 4817 |
if(fv)
|
4711 | 4818 |
{
|
|
4767 | 4874 |
|
4768 | 4875 |
|
4769 | 4876 |
mem_required_for_traversal = fstReaderUint64(xc->f);
|
4770 | |
mem_for_traversal = malloc(mem_required_for_traversal + 66); /* add in potential fastlz overhead */
|
|
4877 |
mem_for_traversal = (unsigned char *)malloc(mem_required_for_traversal + 66); /* add in potential fastlz overhead */
|
4771 | 4878 |
#ifdef FST_DEBUG
|
4772 | 4879 |
fprintf(stderr, FST_APIMESS"sec: %u seclen: %d begtim: %d endtim: %d\n",
|
4773 | 4880 |
secnum, (int)seclen, (int)beg_tim, (int)end_tim);
|
|
4793 | 4900 |
(int)tsec_uclen, (int)tsec_clen, (int)tsec_nitems);
|
4794 | 4901 |
#endif
|
4795 | 4902 |
if(tsec_clen > seclen) break; /* corrupted tsec_clen: by definition it can't be larger than size of section */
|
4796 | |
ucdata = malloc(tsec_uclen);
|
|
4903 |
ucdata = (unsigned char *)malloc(tsec_uclen);
|
4797 | 4904 |
if(!ucdata) break; /* malloc fail as tsec_uclen out of range from corrupted file */
|
4798 | 4905 |
destlen = tsec_uclen;
|
4799 | 4906 |
sourcelen = tsec_clen;
|
|
4802 | 4909 |
|
4803 | 4910 |
if(tsec_uclen != tsec_clen)
|
4804 | 4911 |
{
|
4805 | |
cdata = malloc(tsec_clen);
|
|
4912 |
cdata = (unsigned char *)malloc(tsec_clen);
|
4806 | 4913 |
fstFread(cdata, tsec_clen, 1, xc->f);
|
4807 | 4914 |
|
4808 | 4915 |
rc = uncompress(ucdata, &destlen, cdata, sourcelen);
|
|
4821 | 4928 |
}
|
4822 | 4929 |
|
4823 | 4930 |
free(time_table);
|
4824 | |
time_table = calloc(tsec_nitems, sizeof(uint64_t));
|
|
4931 |
time_table = (uint64_t *)calloc(tsec_nitems, sizeof(uint64_t));
|
4825 | 4932 |
tpnt = ucdata;
|
4826 | 4933 |
tpval = 0;
|
4827 | 4934 |
for(ti=0;ti<tsec_nitems;ti++)
|
|
4832 | 4939 |
tpnt += skiplen;
|
4833 | 4940 |
}
|
4834 | 4941 |
|
4835 | |
tc_head = calloc(tsec_nitems /* scan-build */ ? tsec_nitems : 1, sizeof(uint32_t));
|
|
4942 |
tc_head = (uint32_t *)calloc(tsec_nitems /* scan-build */ ? tsec_nitems : 1, sizeof(uint32_t));
|
4836 | 4943 |
free(ucdata);
|
4837 | 4944 |
}
|
4838 | 4945 |
|
|
4846 | 4953 |
{
|
4847 | 4954 |
if((beg_tim != time_table[0]) || (blocks_skipped))
|
4848 | 4955 |
{
|
4849 | |
unsigned char *mu = malloc(frame_uclen);
|
|
4956 |
unsigned char *mu = (unsigned char *)malloc(frame_uclen);
|
4850 | 4957 |
uint32_t sig_offs = 0;
|
4851 | 4958 |
|
4852 | 4959 |
if(fv)
|
|
4856 | 4963 |
|
4857 | 4964 |
if(beg_tim)
|
4858 | 4965 |
{
|
4859 | |
wx_len = sprintf(wx_buf, "#%"PRIu64"\n", beg_tim);
|
|
4966 |
wx_len = sprintf(wx_buf, "#%" PRIu64 "\n", beg_tim);
|
4860 | 4967 |
fstWritex(xc, wx_buf, wx_len);
|
4861 | 4968 |
}
|
4862 | 4969 |
if((xc->num_blackouts)&&(cur_blackout != xc->num_blackouts))
|
|
4875 | 4982 |
}
|
4876 | 4983 |
else
|
4877 | 4984 |
{
|
4878 | |
unsigned char *mc = malloc(frame_clen);
|
|
4985 |
unsigned char *mc = (unsigned char *)malloc(frame_clen);
|
4879 | 4986 |
int rc;
|
4880 | 4987 |
|
4881 | 4988 |
unsigned long destlen = frame_uclen;
|
|
5060 | 5167 |
#ifdef FST_DEBUG
|
5061 | 5168 |
fprintf(stderr, FST_APIMESS"indx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen);
|
5062 | 5169 |
#endif
|
5063 | |
chain_cmem = malloc(chain_clen);
|
|
5170 |
chain_cmem = (unsigned char *)malloc(chain_clen);
|
5064 | 5171 |
if(!chain_cmem) goto block_err;
|
5065 | 5172 |
fstReaderFseeko(xc, xc->f, indx_pos, SEEK_SET);
|
5066 | 5173 |
fstFread(chain_cmem, chain_clen, 1, xc->f);
|
|
5071 | 5178 |
free(chain_table_lengths);
|
5072 | 5179 |
|
5073 | 5180 |
vc_maxhandle_largest = vc_maxhandle;
|
5074 | |
chain_table = calloc((vc_maxhandle+1), sizeof(off_t));
|
5075 | |
chain_table_lengths = calloc((vc_maxhandle+1), sizeof(uint32_t));
|
|
5181 |
chain_table = (off_t *)calloc((vc_maxhandle+1), sizeof(off_t));
|
|
5182 |
chain_table_lengths = (uint32_t *)calloc((vc_maxhandle+1), sizeof(uint32_t));
|
5076 | 5183 |
}
|
5077 | 5184 |
|
5078 | 5185 |
if(!chain_table || !chain_table_lengths) goto block_err;
|
|
5177 | 5284 |
}
|
5178 | 5285 |
|
5179 | 5286 |
#ifdef FST_DEBUG
|
5180 | |
fprintf(stderr, FST_APIMESS"decompressed chain idx len: %"PRIu32"\n", idx);
|
|
5287 |
fprintf(stderr, FST_APIMESS"decompressed chain idx len: %" PRIu32 "\n", idx);
|
5181 | 5288 |
#endif
|
5182 | 5289 |
|
5183 | 5290 |
mc_mem_len = 16384;
|
5184 | |
mc_mem = malloc(mc_mem_len); /* buffer for compressed reads */
|
|
5291 |
mc_mem = (unsigned char *)malloc(mc_mem_len); /* buffer for compressed reads */
|
5185 | 5292 |
|
5186 | 5293 |
/* check compressed VC data */
|
5187 | 5294 |
if(idx > xc->maxhandle) idx = xc->maxhandle;
|
|
5211 | 5318 |
if(mc_mem_len < chain_table_lengths[i])
|
5212 | 5319 |
{
|
5213 | 5320 |
free(mc_mem);
|
5214 | |
mc_mem = malloc(mc_mem_len = chain_table_lengths[i]);
|
|
5321 |
mc_mem = (unsigned char *)malloc(mc_mem_len = chain_table_lengths[i]);
|
5215 | 5322 |
}
|
5216 | 5323 |
mc = mc_mem;
|
5217 | 5324 |
|
|
5290 | 5397 |
}
|
5291 | 5398 |
}
|
5292 | 5399 |
|
5293 | |
wx_len = sprintf(wx_buf, "#%"PRIu64"\n", time_table[i]);
|
|
5400 |
wx_len = sprintf(wx_buf, "#%" PRIu64 "\n", time_table[i]);
|
5294 | 5401 |
fstWritex(xc, wx_buf, wx_len);
|
5295 | 5402 |
|
5296 | 5403 |
if((xc->num_blackouts)&&(cur_blackout != xc->num_blackouts))
|
|
5390 | 5497 |
|
5391 | 5498 |
vcdid_len = fstVcdIDForFwrite(vcd_id+1, idx+1);
|
5392 | 5499 |
{
|
5393 | |
unsigned char *vesc = malloc(len*4 + 1);
|
|
5500 |
unsigned char *vesc = (unsigned char *)malloc(len*4 + 1);
|
5394 | 5501 |
int vlen = fstUtilityBinToEsc(vesc, vdata, len);
|
5395 | 5502 |
fstWritex(xc, vesc, vlen);
|
5396 | 5503 |
free(vesc);
|
|
5717 | 5824 |
{
|
5718 | 5825 |
uint32_t cur_offs = 0;
|
5719 | 5826 |
|
5720 | |
xc->rvat_sig_offs = calloc(xc->maxhandle, sizeof(uint32_t));
|
|
5827 |
xc->rvat_sig_offs = (uint32_t *)calloc(xc->maxhandle, sizeof(uint32_t));
|
5721 | 5828 |
for(i=0;i<xc->maxhandle;i++)
|
5722 | 5829 |
{
|
5723 | 5830 |
xc->rvat_sig_offs[i] = cur_offs;
|
|
5821 | 5928 |
fprintf(stderr, FST_APIMESS"time section unc: %d, com: %d (%d items)\n",
|
5822 | 5929 |
(int)tsec_uclen, (int)tsec_clen, (int)tsec_nitems);
|
5823 | 5930 |
#endif
|
5824 | |
ucdata = malloc(tsec_uclen);
|
|
5931 |
ucdata = (unsigned char *)malloc(tsec_uclen);
|
5825 | 5932 |
destlen = tsec_uclen;
|
5826 | 5933 |
sourcelen = tsec_clen;
|
5827 | 5934 |
|
5828 | 5935 |
fstReaderFseeko(xc, xc->f, -24 - ((off_t)tsec_clen), SEEK_CUR);
|
5829 | 5936 |
if(tsec_uclen != tsec_clen)
|
5830 | 5937 |
{
|
5831 | |
cdata = malloc(tsec_clen);
|
|
5938 |
cdata = (unsigned char *)malloc(tsec_clen);
|
5832 | 5939 |
fstFread(cdata, tsec_clen, 1, xc->f);
|
5833 | 5940 |
|
5834 | 5941 |
rc = uncompress(ucdata, &destlen, cdata, sourcelen);
|
|
5846 | 5953 |
fstFread(ucdata, tsec_uclen, 1, xc->f);
|
5847 | 5954 |
}
|
5848 | 5955 |
|
5849 | |
xc->rvat_time_table = calloc(tsec_nitems, sizeof(uint64_t));
|
|
5956 |
xc->rvat_time_table = (uint64_t *)calloc(tsec_nitems, sizeof(uint64_t));
|
5850 | 5957 |
tpnt = ucdata;
|
5851 | 5958 |
tpval = 0;
|
5852 | 5959 |
for(ti=0;ti<tsec_nitems;ti++)
|
|
5865 | 5972 |
frame_uclen = fstReaderVarint64(xc->f);
|
5866 | 5973 |
frame_clen = fstReaderVarint64(xc->f);
|
5867 | 5974 |
xc->rvat_frame_maxhandle = fstReaderVarint64(xc->f);
|
5868 | |
xc->rvat_frame_data = malloc(frame_uclen);
|
|
5975 |
xc->rvat_frame_data = (unsigned char *)malloc(frame_uclen);
|
5869 | 5976 |
|
5870 | 5977 |
if(frame_uclen == frame_clen)
|
5871 | 5978 |
{
|
|
5873 | 5980 |
}
|
5874 | 5981 |
else
|
5875 | 5982 |
{
|
5876 | |
unsigned char *mc = malloc(frame_clen);
|
|
5983 |
unsigned char *mc = (unsigned char *)malloc(frame_clen);
|
5877 | 5984 |
int rc;
|
5878 | 5985 |
|
5879 | 5986 |
unsigned long destlen = frame_uclen;
|
|
5906 | 6013 |
#ifdef FST_DEBUG
|
5907 | 6014 |
fprintf(stderr, FST_APIMESS"indx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen);
|
5908 | 6015 |
#endif
|
5909 | |
chain_cmem = malloc(chain_clen);
|
|
6016 |
chain_cmem = (unsigned char *)malloc(chain_clen);
|
5910 | 6017 |
fstReaderFseeko(xc, xc->f, indx_pos, SEEK_SET);
|
5911 | 6018 |
fstFread(chain_cmem, chain_clen, 1, xc->f);
|
5912 | 6019 |
|
5913 | |
xc->rvat_chain_table = calloc((xc->rvat_vc_maxhandle+1), sizeof(off_t));
|
5914 | |
xc->rvat_chain_table_lengths = calloc((xc->rvat_vc_maxhandle+1), sizeof(uint32_t));
|
|
6020 |
xc->rvat_chain_table = (off_t *)calloc((xc->rvat_vc_maxhandle+1), sizeof(off_t));
|
|
6021 |
xc->rvat_chain_table_lengths = (uint32_t *)calloc((xc->rvat_vc_maxhandle+1), sizeof(uint32_t));
|
5915 | 6022 |
|
5916 | 6023 |
pnt = chain_cmem;
|
5917 | 6024 |
idx = 0;
|
|
5920 | 6027 |
if(sectype == FST_BL_VCDATA_DYN_ALIAS2)
|
5921 | 6028 |
{
|
5922 | 6029 |
uint32_t prev_alias = 0;
|
5923 | |
|
|
6030 |
|
5924 | 6031 |
do {
|
5925 | 6032 |
int skiplen;
|
5926 | |
|
|
6033 |
|
5927 | 6034 |
if(*pnt & 0x01)
|
5928 | 6035 |
{
|
5929 | 6036 |
int64_t shval = fstGetSVarint64(pnt, &skiplen) >> 1;
|
|
5938 | 6045 |
xc->rvat_chain_table[idx] = 0; /* need to explicitly zero as calloc above might not run */
|
5939 | 6046 |
xc->rvat_chain_table_lengths[idx] = prev_alias = shval; /* because during this loop iter would give stale data! */
|
5940 | 6047 |
idx++;
|
5941 | |
}
|
|
6048 |
}
|
5942 | 6049 |
else
|
5943 | 6050 |
{
|
5944 | 6051 |
xc->rvat_chain_table[idx] = 0; /* need to explicitly zero as calloc above might not run */
|
|
5949 | 6056 |
else
|
5950 | 6057 |
{
|
5951 | 6058 |
uint64_t val = fstGetVarint32(pnt, &skiplen);
|
5952 | |
|
|
6059 |
|
5953 | 6060 |
fstHandle loopcnt = val >> 1;
|
5954 | 6061 |
for(i=0;i<loopcnt;i++)
|
5955 | 6062 |
{
|
5956 | 6063 |
xc->rvat_chain_table[idx++] = 0;
|
5957 | 6064 |
}
|
5958 | 6065 |
}
|
5959 | |
|
|
6066 |
|
5960 | 6067 |
pnt += skiplen;
|
5961 | 6068 |
} while (pnt != (chain_cmem + chain_clen));
|
5962 | 6069 |
}
|
|
5966 | 6073 |
{
|
5967 | 6074 |
int skiplen;
|
5968 | 6075 |
uint64_t val = fstGetVarint32(pnt, &skiplen);
|
5969 | |
|
|
6076 |
|
5970 | 6077 |
if(!val)
|
5971 | 6078 |
{
|
5972 | 6079 |
pnt += skiplen;
|
|
5990 | 6097 |
xc->rvat_chain_table[idx++] = 0;
|
5991 | 6098 |
}
|
5992 | 6099 |
}
|
5993 | |
|
|
6100 |
|
5994 | 6101 |
pnt += skiplen;
|
5995 | 6102 |
} while (pnt != (chain_cmem + chain_clen));
|
5996 | 6103 |
}
|
|
6015 | 6122 |
}
|
6016 | 6123 |
|
6017 | 6124 |
#ifdef FST_DEBUG
|
6018 | |
fprintf(stderr, FST_APIMESS"decompressed chain idx len: %"PRIu32"\n", idx);
|
|
6125 |
fprintf(stderr, FST_APIMESS"decompressed chain idx len: %" PRIu32 "\n", idx);
|
6019 | 6126 |
#endif
|
6020 | 6127 |
|
6021 | 6128 |
xc->rvat_data_valid = 1;
|
|
6053 | 6160 |
xc->rvat_chain_len = fstReaderVarint32WithSkip(xc->f, &skiplen);
|
6054 | 6161 |
if(xc->rvat_chain_len)
|
6055 | 6162 |
{
|
6056 | |
unsigned char *mu = malloc(xc->rvat_chain_len);
|
6057 | |
unsigned char *mc = malloc(xc->rvat_chain_table_lengths[facidx]);
|
|
6163 |
unsigned char *mu = (unsigned char *)malloc(xc->rvat_chain_len);
|
|
6164 |
unsigned char *mc = (unsigned char *)malloc(xc->rvat_chain_table_lengths[facidx]);
|
6058 | 6165 |
unsigned long destlen = xc->rvat_chain_len;
|
6059 | 6166 |
unsigned long sourcelen = xc->rvat_chain_table_lengths[facidx];
|
6060 | 6167 |
int rc = Z_OK;
|
|
6085 | 6192 |
else
|
6086 | 6193 |
{
|
6087 | 6194 |
int destlen = xc->rvat_chain_table_lengths[facidx] - skiplen;
|
6088 | |
unsigned char *mu = malloc(xc->rvat_chain_len = destlen);
|
|
6195 |
unsigned char *mu = (unsigned char *)malloc(xc->rvat_chain_len = destlen);
|
6089 | 6196 |
fstFread(mu, destlen, 1, xc->f);
|
6090 | 6197 |
/* data to process is for(j=0;j<destlen;j++) in mu[j] */
|
6091 | 6198 |
xc->rvat_chain_mem = mu;
|
|
6386 | 6493 |
c += length;
|
6387 | 6494 |
switch(len) /* all the case statements fall through */
|
6388 | 6495 |
{
|
6389 | |
case 11: c+=((uint32_t)k[10]<<24);
|
6390 | |
case 10: c+=((uint32_t)k[9]<<16);
|
6391 | |
case 9 : c+=((uint32_t)k[8]<<8);
|
|
6496 |
case 11: c+=((uint32_t)k[10]<<24); /* fallthrough */
|
|
6497 |
case 10: c+=((uint32_t)k[9]<<16); /* fallthrough */
|
|
6498 |
case 9 : c+=((uint32_t)k[8]<<8); /* fallthrough */
|
6392 | 6499 |
/* the first byte of c is reserved for the length */
|
6393 | |
case 8 : b+=((uint32_t)k[7]<<24);
|
6394 | |
case 7 : b+=((uint32_t)k[6]<<16);
|
6395 | |
case 6 : b+=((uint32_t)k[5]<<8);
|
6396 | |
case 5 : b+=k[4];
|
6397 | |
case 4 : a+=((uint32_t)k[3]<<24);
|
6398 | |
case 3 : a+=((uint32_t)k[2]<<16);
|
6399 | |
case 2 : a+=((uint32_t)k[1]<<8);
|
|
6500 |
case 8 : b+=((uint32_t)k[7]<<24); /* fallthrough */
|
|
6501 |
case 7 : b+=((uint32_t)k[6]<<16); /* fallthrough */
|
|
6502 |
case 6 : b+=((uint32_t)k[5]<<8); /* fallthrough */
|
|
6503 |
case 5 : b+=k[4]; /* fallthrough */
|
|
6504 |
case 4 : a+=((uint32_t)k[3]<<24); /* fallthrough */
|
|
6505 |
case 3 : a+=((uint32_t)k[2]<<16); /* fallthrough */
|
|
6506 |
case 2 : a+=((uint32_t)k[1]<<8); /* fallthrough */
|
6400 | 6507 |
case 1 : a+=k[0];
|
6401 | 6508 |
/* case 0: nothing left to add */
|
6402 | 6509 |
}
|
|
6431 | 6538 |
|
6432 | 6539 |
if(!*base)
|
6433 | 6540 |
{
|
6434 | |
*base = calloc(1, (hashmask + 1) * sizeof(void *));
|
|
6541 |
*base = (struct collchain_t **)calloc(1, (hashmask + 1) * sizeof(void *));
|
6435 | 6542 |
}
|
6436 | 6543 |
ar = *base;
|
6437 | 6544 |
|
|
6454 | 6561 |
chain = chain->next;
|
6455 | 6562 |
}
|
6456 | 6563 |
|
6457 | |
chain = calloc(1, sizeof(struct collchain_t) + length - 1);
|
|
6564 |
chain = (struct collchain_t *)calloc(1, sizeof(struct collchain_t) + length - 1);
|
6458 | 6565 |
memcpy(chain->mem, mem, length);
|
6459 | 6566 |
chain->fullhash = hf;
|
6460 | 6567 |
chain->length = length;
|
|
6500 | 6607 |
/*** ***/
|
6501 | 6608 |
/************************/
|
6502 | 6609 |
|
6503 | |
int fstUtilityBinToEsc(unsigned char *d, unsigned char *s, int len)
|
6504 | |
{
|
6505 | |
unsigned char *src = s;
|
|
6610 |
int fstUtilityBinToEscConvertedLen(const unsigned char *s, int len)
|
|
6611 |
{
|
|
6612 |
const unsigned char *src = s;
|
|
6613 |
int dlen = 0;
|
|
6614 |
int i;
|
|
6615 |
|
|
6616 |
for(i=0;i<len;i++)
|
|
6617 |
{
|
|
6618 |
switch(src[i])
|
|
6619 |
{
|
|
6620 |
case '\a': /* fallthrough */
|
|
6621 |
case '\b': /* fallthrough */
|
|
6622 |
case '\f': /* fallthrough */
|
|
6623 |
case '\n': /* fallthrough */
|
|
6624 |
case '\r': /* fallthrough */
|
|
6625 |
case '\t': /* fallthrough */
|
|
6626 |
case '\v': /* fallthrough */
|
|
6627 |
case '\'': /* fallthrough */
|
|
6628 |
case '\"': /* fallthrough */
|
|
6629 |
case '\\': /* fallthrough */
|
|
6630 |
case '\?': dlen += 2; break;
|
|
6631 |
default: if((src[i] > ' ') && (src[i] <= '~')) /* no white spaces in output */
|
|
6632 |
{
|
|
6633 |
dlen++;
|
|
6634 |
}
|
|
6635 |
else
|
|
6636 |
{
|
|
6637 |
dlen += 4;
|
|
6638 |
}
|
|
6639 |
break;
|
|
6640 |
}
|
|
6641 |
}
|
|
6642 |
|
|
6643 |
return(dlen);
|
|
6644 |
}
|
|
6645 |
|
|
6646 |
|
|
6647 |
int fstUtilityBinToEsc(unsigned char *d, const unsigned char *s, int len)
|
|
6648 |
{
|
|
6649 |
const unsigned char *src = s;
|
6506 | 6650 |
unsigned char *dst = d;
|
6507 | 6651 |
unsigned char val;
|
6508 | 6652 |
int i;
|
|
6601 | 6745 |
|
6602 | 6746 |
return(dst - s);
|
6603 | 6747 |
}
|
|
6748 |
|
|
6749 |
|
|
6750 |
struct fstETab *fstUtilityExtractEnumTableFromString(const char *s)
|
|
6751 |
{
|
|
6752 |
struct fstETab *et = NULL;
|
|
6753 |
int num_spaces = 0;
|
|
6754 |
int i;
|
|
6755 |
int newlen;
|
|
6756 |
|
|
6757 |
if(s)
|
|
6758 |
{
|
|
6759 |
const char *csp = strchr(s, ' ');
|
|
6760 |
int cnt = atoi(csp+1);
|
|
6761 |
|
|
6762 |
for(;;)
|
|
6763 |
{
|
|
6764 |
csp = strchr(csp+1, ' ');
|
|
6765 |
if(csp) { num_spaces++; } else { break; }
|
|
6766 |
}
|
|
6767 |
|
|
6768 |
if(num_spaces == (2*cnt))
|
|
6769 |
{
|
|
6770 |
char *sp, *sp2;
|
|
6771 |
|
|
6772 |
et = (struct fstETab*)calloc(1, sizeof(struct fstETab));
|
|
6773 |
et->elem_count = cnt;
|
|
6774 |
et->name = strdup(s);
|
|
6775 |
et->literal_arr = (char**)calloc(cnt, sizeof(char *));
|
|
6776 |
et->val_arr = (char**)calloc(cnt, sizeof(char *));
|
|
6777 |
|
|
6778 |
sp = strchr(et->name, ' ');
|
|
6779 |
*sp = 0;
|
|
6780 |
|
|
6781 |
sp = strchr(sp+1, ' ');
|
|
6782 |
|
|
6783 |
for(i=0;i<cnt;i++)
|
|
6784 |
{
|
|
6785 |
sp2 = strchr(sp+1, ' ');
|
|
6786 |
*(char*)sp2 = 0;
|
|
6787 |
et->literal_arr[i] = sp+1;
|
|
6788 |
sp = sp2;
|
|
6789 |
|
|
6790 |
newlen = fstUtilityEscToBin(NULL, (unsigned char*)et->literal_arr[i], strlen(et->literal_arr[i]));
|
|
6791 |
et->literal_arr[i][newlen] = 0;
|
|
6792 |
}
|
|
6793 |
|
|
6794 |
for(i=0;i<cnt;i++)
|
|
6795 |
{
|
|
6796 |
sp2 = strchr(sp+1, ' ');
|
|
6797 |
if(sp2) { *sp2 = 0; }
|
|
6798 |
et->val_arr[i] = sp+1;
|
|
6799 |
sp = sp2;
|
|
6800 |
|
|
6801 |
newlen = fstUtilityEscToBin(NULL, (unsigned char*)et->val_arr[i], strlen(et->val_arr[i]));
|
|
6802 |
et->val_arr[i][newlen] = 0;
|
|
6803 |
}
|
|
6804 |
}
|
|
6805 |
}
|
|
6806 |
|
|
6807 |
return(et);
|
|
6808 |
}
|
|
6809 |
|
|
6810 |
|
|
6811 |
void fstUtilityFreeEnumTable(struct fstETab *etab)
|
|
6812 |
{
|
|
6813 |
if(etab)
|
|
6814 |
{
|
|
6815 |
free(etab->literal_arr);
|
|
6816 |
free(etab->val_arr);
|
|
6817 |
free(etab->name);
|
|
6818 |
free(etab);
|
|
6819 |
}
|
|
6820 |
}
|