* So we'll have to realloc() on the way...
* we'll wait until we can calculate yynxt_tbl->td_hilen.
*/
- yynxt_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct
- yytbl_data));
+ yynxt_tbl = calloc(1, sizeof (struct yytbl_data));
+
yytbl_data_init (yynxt_tbl, YYTD_ID_NXT);
yynxt_tbl->td_hilen = 1;
yynxt_tbl->td_lolen = num_full_table_rows;
yynxt_tbl->td_data = yynxt_data =
- (flex_int32_t *) calloc (yynxt_tbl->td_lolen *
+ calloc(yynxt_tbl->td_lolen *
yynxt_tbl->td_hilen,
sizeof (flex_int32_t));
yynxt_curr = 0;
/* Each time we hit here, it's another td_hilen, so we realloc. */
yynxt_tbl->td_hilen++;
yynxt_tbl->td_data = yynxt_data =
- (flex_int32_t *) realloc (yynxt_data,
+ realloc (yynxt_data,
yynxt_tbl->td_hilen *
yynxt_tbl->td_lolen *
sizeof (flex_int32_t));
void flex_free PROTO ((void *));
#define allocate_integer_array(size) \
- (int *) allocate_array( size, sizeof( int ) )
+ allocate_array(size, sizeof(int))
#define reallocate_integer_array(array,size) \
- (int *) reallocate_array( (void *) array, size, sizeof( int ) )
+ reallocate_array((void *) array, size, sizeof(int))
#define allocate_bool_array(size) \
- (bool *) allocate_array( size, sizeof( bool ) )
+ allocate_array(size, sizeof(bool))
#define reallocate_bool_array(array,size) \
- (bool *) reallocate_array( (void *) array, size, sizeof( bool ) )
+ reallocate_array((void *) array, size, sizeof(bool))
#define allocate_int_ptr_array(size) \
- (int **) allocate_array( size, sizeof( int * ) )
+ allocate_array(size, sizeof(int *))
#define allocate_char_ptr_array(size) \
- (char **) allocate_array( size, sizeof( char * ) )
+ allocate_array(size, sizeof(char *))
#define allocate_dfaacc_union(size) \
- (union dfaacc_union *) \
- allocate_array( size, sizeof( union dfaacc_union ) )
+ allocate_array(size, sizeof(union dfaacc_union))
#define reallocate_int_ptr_array(array,size) \
- (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
+ reallocate_array((void *) array, size, sizeof(int *))
#define reallocate_char_ptr_array(array,size) \
- (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
+ reallocate_array((void *) array, size, sizeof(char *))
#define reallocate_dfaacc_union(array, size) \
- (union dfaacc_union *) \
- reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
+ reallocate_array((void *) array, size, sizeof(union dfaacc_union))
#define allocate_character_array(size) \
- (char *) allocate_array( size, sizeof( char ) )
+ allocate_array( size, sizeof(char))
#define reallocate_character_array(array,size) \
- (char *) reallocate_array( (void *) array, size, sizeof( char ) )
+ reallocate_array((void *) array, size, sizeof(char))
#define allocate_Character_array(size) \
- (unsigned char *) allocate_array( size, sizeof( unsigned char ) )
+ allocate_array(size, sizeof(unsigned char))
#define reallocate_Character_array(array,size) \
- (unsigned char *) reallocate_array( (void *) array, size, sizeof( unsigned char ) )
+ reallocate_array((void *) array, size, sizeof(unsigned char))
/* Used to communicate between scanner and parser. The type should really
flex_int8_t *tdata = 0;
struct yytbl_data *tbl;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
+ tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (tbl, YYTD_ID_RULE_CAN_MATCH_EOL);
tbl->td_flags = YYTD_DATA8;
tbl->td_lolen = num_rules + 1;
tbl->td_data = tdata =
- (flex_int8_t *) calloc (tbl->td_lolen, sizeof (flex_int8_t));
+ calloc(tbl->td_lolen, sizeof (flex_int8_t));
for (i = 1; i <= num_rules; i++)
tdata[i] = rule_has_nl[i] ? 1 : 0;
((tblend + numecs + 1) >= INT16_MAX
|| long_align) ? "flex_int32_t" : "flex_int16_t");
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
+ tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (tbl, YYTD_ID_TRANSITION);
tbl->td_flags = YYTD_DATA32 | YYTD_STRUCT;
tbl->td_hilen = 0;
tbl->td_lolen = tblend + numecs + 1; /* number of structs */
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen * 2, sizeof (flex_int32_t));
+ calloc(tbl->td_lolen * 2, sizeof (flex_int32_t));
/* We want the transition to be represented as the offset to the
* next state, not the actual state number, which is what it currently
flex_int32_t *tdata = 0;
flex_int32_t i;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
+ tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (tbl, YYTD_ID_START_STATE_LIST);
tbl->td_flags = YYTD_DATA32 | YYTD_PTRANS;
tbl->td_hilen = 0;
tbl->td_lolen = lastsc * 2 + 1;
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(tbl->td_lolen, sizeof (flex_int32_t));
for (i = 0; i <= lastsc * 2; ++i)
tdata[i] = base[i];
struct yytbl_data *tbl = 0;
flex_int32_t *tdata = 0;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
+ tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (tbl, YYTD_ID_EC);
tbl->td_flags |= YYTD_DATA32;
tbl->td_hilen = 0;
tbl->td_lolen = csize;
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(tbl->td_lolen, sizeof (flex_int32_t));
for (i = 1; i < csize; ++i) {
ecgroup[i] = ABS (ecgroup[i]);
struct yytbl_data *tbl;
flex_int32_t *tdata = 0;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
+ tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (tbl, YYTD_ID_ACCEPT);
tbl->td_flags |= YYTD_DATA32;
tbl->td_hilen = 0; /* it's a one-dimensional array */
tbl->td_lolen = lastdfa + 1;
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(tbl->td_lolen, sizeof (flex_int32_t));
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
"\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
- yyacclist_tbl = (struct yytbl_data*)calloc(1,sizeof(struct yytbl_data));
+ yyacclist_tbl = calloc(1,sizeof(struct yytbl_data));
yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST);
yyacclist_tbl->td_lolen = MAX(numas,1) + 1;
yyacclist_tbl->td_data = yyacclist_data =
- (flex_int32_t *) calloc (yyacclist_tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(yyacclist_tbl->td_lolen, sizeof (flex_int32_t));
yyacclist_curr = 1;
j = 1; /* index into "yy_acclist" array */
"\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
- yyacc_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
+ yyacc_tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT);
yyacc_tbl->td_lolen = k;
yyacc_tbl->td_data = yyacc_data =
- (flex_int32_t *) calloc (yyacc_tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(yyacc_tbl->td_lolen, sizeof (flex_int32_t));
yyacc_curr=1;
for (i = 1; i <= lastdfa; ++i) {
* templates with).
*/
flex_int32_t *yymecs_data = 0;
- yymeta_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct
- yytbl_data));
+ yymeta_tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (yymeta_tbl, YYTD_ID_META);
yymeta_tbl->td_lolen = numecs + 1;
yymeta_tbl->td_data = yymecs_data =
- (flex_int32_t *) calloc (yymeta_tbl->td_lolen,
+ calloc(yymeta_tbl->td_lolen,
sizeof (flex_int32_t));
if (trace)
"\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n",
(tblend >= INT16_MAX
|| long_align) ? "flex_uint32_t" : "flex_uint16_t");
- yybase_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
+ yybase_tbl = calloc (1, sizeof (struct yytbl_data));
yytbl_data_init (yybase_tbl, YYTD_ID_BASE);
yybase_tbl->td_lolen = total_states + 1;
yybase_tbl->td_data = yybase_data =
- (flex_int32_t *) calloc (yybase_tbl->td_lolen,
+ calloc(yybase_tbl->td_lolen,
sizeof (flex_int32_t));
yybase_curr = 1;
(total_states >= INT16_MAX
|| long_align) ? "flex_int32_t" : "flex_int16_t");
- yydef_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
+ yydef_tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (yydef_tbl, YYTD_ID_DEF);
yydef_tbl->td_lolen = total_states + 1;
yydef_tbl->td_data = yydef_data =
- (flex_int32_t *) calloc (yydef_tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(yydef_tbl->td_lolen, sizeof (flex_int32_t));
for (i = 1; i <= total_states; ++i) {
mkdata (def[i]);
(total_states >= INT16_MAX
|| long_align) ? "flex_uint32_t" : "flex_uint16_t");
- yynxt_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
+ yynxt_tbl = calloc (1, sizeof (struct yytbl_data));
yytbl_data_init (yynxt_tbl, YYTD_ID_NXT);
yynxt_tbl->td_lolen = tblend + 1;
yynxt_tbl->td_data = yynxt_data =
- (flex_int32_t *) calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t));
+ calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t));
for (i = 1; i <= tblend; ++i) {
/* Note, the order of the following test is important.
(total_states >= INT16_MAX
|| long_align) ? "flex_int32_t" : "flex_int16_t");
- yychk_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
+ yychk_tbl = calloc (1, sizeof (struct yytbl_data));
yytbl_data_init (yychk_tbl, YYTD_ID_CHK);
yychk_tbl->td_lolen = tblend + 1;
yychk_tbl->td_data = yychk_data =
- (flex_int32_t *) calloc (yychk_tbl->td_lolen, sizeof (flex_int32_t));
+ calloc(yychk_tbl->td_lolen, sizeof (flex_int32_t));
for (i = 1; i <= tblend; ++i) {
if (chk[i] == 0)
(fullspd) ? "struct yy_trans_info*" :
"flex_int32_t");
- yynultrans_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct
- yytbl_data));
+ yynultrans_tbl = calloc(1, sizeof (struct yytbl_data));
yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS);
if (fullspd)
yynultrans_tbl->td_flags |= YYTD_PTRANS;
yynultrans_tbl->td_lolen = lastdfa + 1;
yynultrans_tbl->td_data = yynultrans_data =
- (flex_int32_t *) calloc (yynultrans_tbl->td_lolen,
+ calloc(yynultrans_tbl->td_lolen,
sizeof (flex_int32_t));
for (i = 1; i <= lastdfa; ++i) {
if (!tablesfilename) {
nbytes = strlen (prefix) + strlen (tablesfile_template) + 2;
- tablesfilename = pname = (char *) calloc (nbytes, 1);
+ tablesfilename = pname = calloc(nbytes, 1);
snprintf (pname, nbytes, tablesfile_template, prefix);
}
yytbl_writer_init (&tableswr, tablesout);
nbytes = strlen (prefix) + strlen ("tables") + 2;
- tablesname = (char *) calloc (nbytes, 1);
+ tablesname = calloc(nbytes, 1);
snprintf (tablesname, nbytes, "%stables", prefix);
yytbl_hdr_init (&hdr, flex_version, tablesname);
void *flex_alloc( size_t size )
{
- return (void *) malloc( size );
+ return malloc(size);
}
void *flex_realloc( void *ptr, size_t size )
{
- return (void *) realloc( ptr, size );
+ return realloc(ptr, size);
}
void flex_free( void *ptr )
{
int i;
struct _scanopt_t *s;
- s = (struct _scanopt_t *) malloc (sizeof (struct _scanopt_t));
+ s = malloc(sizeof (struct _scanopt_t));
s->options = options;
s->optc = 0;
s->optc++;
/* Build auxiliary data */
- s->aux = (struct _aux *) malloc (s->optc * sizeof (struct _aux));
+ s->aux = malloc(s->optc * sizeof (struct _aux));
for (i = 0; i < s->optc; i++) {
const unsigned char *p, *pname;
fprintf (fp, "\n");
/* Sort by r_val and string. Yes, this is O(n*n), but n is small. */
- store = (usg_elem *) malloc (s->optc * sizeof (usg_elem));
+ store = malloc(s->optc * sizeof (usg_elem));
for (i = 0; i < s->optc; i++) {
/* grab the next preallocate node. */
static char* STRDUP(char* s1)
{
- char* s2 = (char*)malloc(strlen(s1)+1);
+ char* s2 = malloc(strlen(s1)+1);
sprintf(s2,"%s",s1);
return s2;
}
static char* STRDUP(char* s1)
{
- char* s2 = (char*)malloc(strlen(s1)+1);
+ char* s2 = malloc(strlen(s1)+1);
sprintf(s2,"%s",s1);
return s2;
}
static char* STRDUP(char* s1)
{
- char* s2 = (char*)malloc(strlen(s1)+1);
+ char* s2 = malloc(strlen(s1)+1);
sprintf(s2,"%s",s1);
return s2;
}
int i;
total_mem += n;
- p = (void*)malloc(n);
+ p = malloc(n);
if( nptrs >= arrsz){
/* increase array size by 1 */
arrsz++;
- ptrs = (struct memsz*)realloc( ptrs, arrsz * sizeof(struct memsz));
+ ptrs = realloc(ptrs, arrsz * sizeof(struct memsz));
ptrs[nptrs].p = 0;
ptrs[nptrs].sz = 0;
}
if ( ptrs[i].p == p){
total_mem -= ptrs[i].sz;
total_mem += n;
- ptrs[i].p = (void*)realloc(p,n);
+ ptrs[i].p = realloc(p,n);
ptrs[i].sz = n;
printf("yyflex_realloc(%#10lx,%8ld) total=%8ld return=%8lx\n",
main ()
{
arrsz = 1;
- ptrs = (struct memsz*)calloc(1,sizeof(struct memsz));
+ ptrs = calloc(1, sizeof(struct memsz));
nptrs = 0;
yyin = stdin;
int i;
total_mem += n;
- p = (void*)malloc(n);
+ p = malloc(n);
if( nptrs >= arrsz){
/* increase array size by 1 */
arrsz++;
- ptrs = (struct memsz*)realloc( ptrs, arrsz * sizeof(struct memsz));
+ ptrs = realloc(ptrs, arrsz * sizeof(struct memsz));
ptrs[nptrs].p = 0;
ptrs[nptrs].sz = 0;
}
if ( ptrs[i].p == p){
total_mem -= ptrs[i].sz;
total_mem += n;
- ptrs[i].p = (void*)realloc(p,n);
+ ptrs[i].p = realloc(p, n);
ptrs[i].sz = n;
printf("yyflex_realloc(%#10lx,%8ld) total=%8ld return=%8lx\n",
{
yyscan_t scanner;
arrsz = 1;
- ptrs = (struct memsz*)calloc(1,sizeof(struct memsz));
+ ptrs = calloc(1, sizeof(struct memsz));
nptrs = 0;
yylex_init(&scanner);
}
/* Allocate and initialize the locks. One for each filename in ARGV. */
- file_locks = (pthread_mutex_t*)malloc( (ARGC-1) * sizeof(pthread_mutex_t));
+ file_locks = malloc((ARGC-1) * sizeof(pthread_mutex_t));
for( i = 0; i < ARGC-1; i++)
pthread_mutex_init( &file_locks[i], NULL );
We make a copy, since the buffer will be modified by flex.*/
printf("Testing: yy_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
len = strlen(INPUT_STRING_1) + 2;
- buf = (char*)malloc( len );
+ buf = malloc(len);
strcpy( buf, INPUT_STRING_1);
buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */
buf[ len -1 ] =0;
We make a copy, since the buffer will be modified by flex.*/
printf("Testing: yy_scan_buffer(%s): ",INPUT_STRING_1); fflush(stdout);
len = strlen(INPUT_STRING_1) + 2;
- buf = (char*)malloc( len );
+ buf = malloc(len);
strcpy( buf, INPUT_STRING_1);
buf[ len -2 ] = 0; /* Flex requires two NUL bytes at end of buffer. */
buf[ len -1 ] =0;
struct Buffer * buf;
int i;
- buf = (struct Buffer*) malloc(sizeof(struct Buffer));
+ buf = malloc(sizeof(struct Buffer));
buf->curr_len =0;
buf->max_len = 4;
buf->grow_len = 100;
- buf->data = (char*)malloc(buf->max_len);
+ buf->data = malloc(buf->max_len);
testlex_init(&scanner);
testset_in( stdin, scanner);
if( buf->curr_len >= buf->max_len )
{
- new_buf = (struct Buffer*) malloc(sizeof(struct Buffer));
+ new_buf = malloc(sizeof(struct Buffer));
new_buf->max_len = buf->max_len + buf->grow_len;
new_buf->grow_len = buf->grow_len;
- new_buf->data = (char*)malloc(new_buf->max_len);
+ new_buf->data = malloc(new_buf->max_len);
for( new_buf->curr_len = 0;
new_buf->curr_len < buf->curr_len;
new_buf->curr_len++ )
void *flex_alloc( size )
size_t size;
{
- return (void *) malloc( size );
+ return malloc(size);
}
void *flex_realloc( ptr, size )
void *ptr;
size_t size;
{
- return (void *) realloc( ptr, size );
+ return realloc(ptr, size);
}
void flex_free( ptr )