1.1 --- a/test/testdata.c Tue Jul 11 01:35:27 2006 +0000
1.2 +++ b/test/testdata.c Sun Aug 06 09:43:03 2006 +0000
1.5 - * $Id: testdata.c,v 1.1 2006-07-11 01:35:23 nkeynes Exp $
1.6 + * $Id: testdata.c,v 1.2 2006-08-02 04:13:15 nkeynes Exp $
1.13 current_size = DEFAULT_SIZE;
1.14 - test_data_t test = calloc(current_size, 1);
1.15 + test_data_t test = malloc(current_size);
1.16 + memset( test, 0, current_size );
1.18 dataptr = (char *)(test+1);
1.20 @@ -120,9 +121,10 @@
1.21 if( equals != NULL ) {
1.22 char *block_name = line;
1.25 - while( isspace(*equals) )
1.29 + while( isspace(*p) )
1.31 len = strlen(line)+1;
1.32 if( dataptr + len > current_end ) {
1.33 current_end += current_size;
1.34 @@ -137,50 +139,56 @@
1.35 dataptr = ALIGN_32(dataptr+len);
1.36 current->item[current_block].data = dataptr;
1.37 current->item[current_block].length = 0;
1.40 - if( current == NULL || current_block == -1 )
1.42 - char *p = strtok(line, "\t\r\n ");
1.43 - while( p != NULL ) {
1.44 - if( dataptr + 8 > current_end ) {
1.45 - current_end += current_size;
1.46 - current_size *= 2;
1.47 - current = realloc(current, current_size );
1.48 - if( last != NULL )
1.49 - last->next = current;
1.52 + while( isspace(*line) )
1.57 + if( current == NULL || current_block == -1 )
1.59 + char *p = strtok(line, "\t\r\n ");
1.60 + while( p != NULL ) {
1.61 + if( dataptr + 8 > current_end ) {
1.62 + int old_size = current_size;
1.63 + current_end += current_size;
1.64 + current_size *= 2;
1.65 + current = realloc(current, current_size );
1.66 + memset( current + old_size, 0, old_size );
1.67 + if( last != NULL )
1.68 + last->next = current;
1.70 + int len = strlen(p);
1.72 + char *dot = strchr(p, '.');
1.73 + if( dot != NULL ) { /* FP */
1.74 + if( p[len-1] == 'L' ) { /* Ending in L */
1.76 + double d = strtod(p, NULL);
1.77 + *((double *)dataptr) = d;
1.80 + float f = (float)strtod(p,NULL);
1.81 + *((float *)dataptr) = f;
1.84 - int len = strlen(p);
1.86 - char *dot = strchr(p, '.');
1.87 - if( dot != NULL ) { /* FP */
1.88 - if( p[len-1] == 'L' ) { /* Ending in L */
1.90 - double d = strtod(p, NULL);
1.91 - *((double *)dataptr) = d;
1.94 - float f = (float)strtod(p,NULL);
1.95 - *((float *)dataptr) = f;
1.99 - unsigned long value = strtoul(p, NULL, 16);
1.101 - *((unsigned int *)dataptr) = value;
1.103 - } else if( len == 4 ) {
1.104 - *((unsigned short *)dataptr) = value;
1.106 - } else if( len == 2 ) {
1.107 - *((unsigned char *)dataptr) = value;
1.111 + unsigned long value = strtoul(p, NULL, 16);
1.113 + *((unsigned int *)dataptr) = value;
1.115 + } else if( len == 4 ) {
1.116 + *((unsigned short *)dataptr) = value;
1.118 + } else if( len == 2 ) {
1.119 + *((unsigned char *)dataptr) = value;
1.122 - dataptr += datalen;
1.123 - current->item[current_block].length += datalen;
1.124 - p = strtok(NULL, "\t\r\n ");
1.126 + dataptr += datalen;
1.127 + current->item[current_block].length += datalen;
1.128 + p = strtok(NULL, "\t\r\n ");