Exemple #1
0
static t_to_free	*init_push(t_to_free *to_free)
{
	if (to_free == NULL)
		return (lst_init());
	else
		return (lst_fpush(to_free));
}
Exemple #2
0
t_suite			*suite_create(char *name, t_suite_fn *fn)
{
	t_suite	*suite;

	suite = (t_suite *)malloc(sizeof(t_suite));
	suite->name = strdup(name);

	suite->tests = lst_init();
	suite->fn = fn;
	return (suite);
}
table_t *tbl_init() {
	int i;
	table_t *ct = (table_t *)malloc(sizeof(table_t));

	ct->max_size = HASH_SIZE;
	ct->curr_size = 0;
	ct->map = (list_t **)malloc(HASH_SIZE * sizeof(list_t *));
	for (i = 0; i < HASH_SIZE; i++)
		ct->map[i] = lst_init();
	return ct;
}
Exemple #4
0
int             main(void)
{
    t_elem      *lst_elem;

    lst_elem = NULL;
    lst_init(lst_elem);
    get_elem(lst_elem);
    print_list(lst_elem);
    // while(!getnextlineisblank)


    return (0);
}
Exemple #5
0
void
main (void)
{
  LIST *list;
  int done = 0;
  REC *rec;
  char line[80];

  list = lst_init ();

  printf ("Type a list of names and ages. Empty line quits\n\n");

  while (!done)
    {
      rec = lst_newnode (sizeof (REC));
      gets (line);
      if ((done = (line[0] == '\0')) != 1)
	{
	  strcpy (rec->name, line);
	  gets (line);
	  rec->age = atoi (line);
	  lst_insertafter (list, rec, LST_HEAD (list));
	}
    };

  printf ("\nThe list you typed in was:\n\n");

  for (rec = lst_first (list); rec; rec = lst_next (rec))
    printf ("Name: %s, Age: %d\n", rec->name, rec->age);

  printf ("\nSorting the list...\n\n");

  lst_mergesort (list, my_cmp);

  for (rec = lst_first (list); rec; rec = lst_next (rec))
    printf ("Name: %s, Age: %d\n", rec->name, rec->age);

  lst_kill (list, lst_freenode);
}
Exemple #6
0
int main( int argc, char *argv[] )
{
  extern char *optarg;
  extern int optind;
  int c;
  int usage = 0;
  int memory_dump = 0;
  int dos_newlines = 0;
  char *pc;
  int  cmd_processor = 0;
  char *processor_name = NULL;

  state.i_memory = i_memory_create();
  
  state.pass = 0;
  state.quiet = 0;

  #ifdef PARSE_DEBUG
  {
    extern int yydebug;
    yydebug = 1; /* enable parse debug */
  }
  #endif

  #ifdef USE_GPASM_HEADER_PATH
    /* add the header path to the include paths list */
    #ifndef __MSDOS__
      include_paths[n_include_paths++] = GPASM_HEADER_PATH;
    #else
      include_paths[n_include_paths++] = "c:\\gputils\\header";    
    #endif
  #endif

  while ((c = GETOPT_FUNC) != EOF) {
    switch (c) {
    case '?':
    case 'h':
      usage = 1;
      break;
    case 'a':
      select_hexformat(optarg);
      state.cmd_line.hex_format = 1;
      break;
    case 'c':
      state.case_insensitive = 1;
      if (state.stDefines != NULL) {
        printf("Warning: The -c option must be called before the -d option.\n");
      }
      break;
    case 'D':
    case 'd':
      if ((optarg != NULL) && (strlen(optarg) > 0)) {
	struct symbol *sym;
	char *lhs, *rhs;

        /* the Defines symbol table is not yet defined*/
        if (state.stDefines == NULL) {
          state.stDefines = push_symbol_table(NULL, state.case_insensitive);
        }

	lhs = strdup(optarg);
	rhs = strchr(lhs, '=');
	if (rhs != NULL) {
	  *rhs = '\0';	/* Terminate the left-hand side */
	  rhs++;	/* right-hand side begins after the '=' */
	}

	sym = get_symbol(state.stDefines, lhs);
	if (sym == NULL)
	  sym = add_symbol(state.stDefines, lhs);
	if (rhs)
	  annotate_symbol(sym, rhs);
      }
      break;
    case 'e':
      select_expand(optarg);
      state.cmd_line.macro_expand = 1;
      break;
    case 'I':
       if(n_include_paths < MAX_INCLUDE_PATHS) {
 	 include_paths[n_include_paths++] = optarg;
       } else {
 	 fprintf(stderr, "too many -I paths\n");
 	 exit(1);
       }
       break;    
 
    case 'l':
      dump_processor_list();
      exit(0);
      break;
    case 'm':
      memory_dump = 1;
      break;
    case 'n':
      #ifndef __MSDOS__
        dos_newlines = 1;
      #endif
      break;
    case 'o':
	    strcpy(state.hexfilename, optarg);
	    strcpy(state.basefilename, optarg);
	    pc = strrchr(state.basefilename, '.');
	    if (pc)
		   *pc = 0;
      break;
    case 'p':
      cmd_processor = 1;
      processor_name = optarg;
      break;
    case 'q':
      state.quiet = 1;
      break;
    case 'r':
      select_radix(optarg);
      state.cmd_line.radix = 1;
      break;
    case 'w':
      select_errorlevel(atoi(optarg));
      state.cmd_line.error_level = 1;
      break;
    case 'v':
      fprintf(stderr, "%s\n", GPASM_VERSION_STRING);
      exit(0);
      
    }
    if (usage)
      break;
  }
  
  if (optind < argc)
    state.srcfilename = argv[optind];
  else
    usage = 1;

  if (usage) {
    show_usage();
  }

  if(state.basefilename[0] == '\0') {
	  strcpy(state.basefilename, state.srcfilename);
	  pc = strrchr(state.basefilename, '.');
	  if (pc)
		  *pc = 0;
  }

  /* the Defines symbol table is not yet defined*/
  if (state.stDefines == NULL) {
    state.stDefines = push_symbol_table(NULL, state.case_insensitive);
  }

  /* Builtins are always case insensitive */
  state.stBuiltin = push_symbol_table(NULL, 1);
  state.stDirective = state.stBuiltin;
  state.stMacros = push_symbol_table(NULL, state.case_insensitive);
  state.stTop = 
    state.stGlobal = push_symbol_table(NULL, state.case_insensitive);

  opcode_init(0);

  /* the tables are built, select the processor if -p was used */
  if (cmd_processor) {
    select_processor(processor_name);
    state.cmd_line.processor = 1;
  }

  state.maxram = (MAX_RAM - 1);

  open_src(state.srcfilename, 0);
  state.pass = 1;
  yyparse();
 
  open_src(state.srcfilename, 0);
  state.pass++;
  state.org = 0;
  state.cblock = 0;
  if (state.cmd_line.radix != 1)
    state.radix = 16;
  cod_init();
  lst_init();
  yyparse();

  assert(state.pass == 2);
  
  pop_symbol_table(state.stBuiltin);
  
  if (check_writehex(state.i_memory, state.hex_format)) {
    gperror(GPE_IHEX,NULL); 
  } else {
    int byte_words;
    
    if (state.device.core_size > 0xff) {
      byte_words = 0;
    } else {
      byte_words = 1;
      if (state.hex_format != inhx8m) {
        gpwarning(GPW_UNKNOWN,"Must use inhx8m format for EEPROM8");
        state.hex_format = inhx8m;
      }
    }
    
    if (writehex(state.basefilename, state.i_memory, 
                 state.hex_format, state.num.errors,
                 byte_words, dos_newlines)) {
      gperror(GPE_UNKNOWN,"Error generating hex file");
    }
  }

  if(memory_dump)
    print_i_memory(state.i_memory);

  /* Maybe produce a symbol table */
  if (state.lst.symboltable) {
    lst_throw(); /* Start symbol table on a fresh page */
    lst_symbol_table(state.stGlobal);
    lst_defines_table(state.stDefines);
  }

  /* Maybe produce a memory map */
  if (state.lst.memorymap) {
    lst_memory_map(state.i_memory);
  }
  
  /* Finish off the listing and symbol files*/
  lst_close();
  if (state.processor_info)
    cod_close_file();
  free_files();

  if (state.num.errors > 0)
    return 1;
  else
    return 0;
}
Exemple #7
0
int
assemble(void)
{
  char *pc; 
  struct symbol_table *cmd_defines;

  /* store the command line defines to restore on second pass */
  cmd_defines = state.stDefines;
  state.c_memory = state.i_memory = i_memory_create();

  if(state.basefilename[0] == '\0') {
    strcpy(state.basefilename, state.srcfilename);
    pc = strrchr(state.basefilename, '.');
    if (pc)
      *pc = 0;
  }

  /* Builtins are always case insensitive */
  state.stBuiltin = push_symbol_table(NULL, 1);
  state.stDirective = state.stBuiltin;
  state.stMacros = push_symbol_table(NULL, state.case_insensitive);
  state.stTop = 
    state.stGlobal = push_symbol_table(NULL, state.case_insensitive);
  state.stTopDefines = 
    state.stDefines = push_symbol_table(cmd_defines, state.case_insensitive);

  opcode_init(0);

  /* the tables are built, select the processor if -p was used */
  if (cmd_processor) {
    select_processor(processor_name);
    state.cmd_line.processor = 1;
  }

  state.pass = 1;
  open_src(state.srcfilename, 0);
  yyparse();
 
  state.pass++;
  state.org = 0;
  state.cblock = 0;
  /* clean out defines for second pass */
  state.stTopDefines = 
    state.stDefines = push_symbol_table(cmd_defines, state.case_insensitive);
  if (state.cmd_line.radix != 1)
    state.radix = 16;
  state.obj.symbol_num = 0;
  state.obj.section_num = 0;
  state.obj.org_num = 0;
  state.found_config = 0;
  state.found_devid = 0;
  state.found_idlocs = 0;
  coff_init();
  cod_init();
  lst_init();
  open_src(state.srcfilename, 0);
  yyparse();

  assert(state.pass == 2);
  
  pop_symbol_table(state.stBuiltin);
  
  hex_init();

  if(state.memory_dump)
    print_i_memory(state.i_memory, 
                   state.device.class == PROC_CLASS_PIC16E ? 1 : 0);

  /* Maybe produce a symbol table */
  if (state.lst.symboltable) {
    lst_throw(); /* Start symbol table on a fresh page */
    lst_symbol_table(state.stGlobal);
    lst_defines_table(state.stDefines);
  }

  /* Maybe produce a memory map */
  if ((state.mode == absolute) && (state.lst.memorymap)) {
    lst_memory_map(state.i_memory);
  }
  
  /* Finish off the object, listing, and symbol files*/
  coff_close_file();
  lst_close();
  if (state.processor_info)
    cod_close_file();
  free_files();

  if ((state.num.errors > 0) ||
      (gp_num_errors > 0))
    return EXIT_FAILURE;
  else
    return EXIT_SUCCESS;
}
Exemple #8
0
int
dspio_readHB_mat_double( const char* filename,
                         int row_i, int row_f,
                         int** p_rowptr,
                         int* p_nnz,
                         int** p_colind,
                         double** p_val )
{
/****************************************************************************/
/*  This function opens and reads the specified file, interpreting its      */
/*  contents as a sparse matrix stored in the Harwell/Boeing standard       */
/*  format and creating compressed column storage scheme vectors to hold    */
/*  the index and nonzero value information.                                */
/*                                                                          */
/*    ----------                                                            */
/*    **CAVEAT**                                                            */
/*    ----------                                                            */
/*  Parsing real formats from Fortran is tricky, and this file reader       */
/*  does not claim to be foolproof.   It has been tested for cases when     */
/*  the real values are printed consistently and evenly spaced on each      */
/*  line, with Fixed (F), and Exponential (E or D) formats.                 */
/*                                                                          */
/*  **  If the input file does not adhere to the H/B format, the  **        */
/*  **             results will be unpredictable.                 **        */
/*                                                                          */
/****************************************************************************/
  FILE *in_file;
  int i,j,ind,col,offset,count,last,Nrhs;
  int Ptrcrd, Indcrd, Valcrd, Rhscrd;
  int Nrow, Ncol, Nnzero;
  int Ptrperline, Ptrwidth, Indperline, Indwidth;
  int Valperline, Valwidth, Valprec;
  int Valflag;           /* Indicates 'E','D', or 'F' float format */
  char* ThisElement;
  char Title[73], Key[9], Type[4], Rhstype[4];
  char Ptrfmt[17], Indfmt[17], Valfmt[21], Rhsfmt[21];
  char line[BUFSIZ];

  int* rowptr;
  int* colind;
  int  len_colind;
  double* val;
  int  nr = row_f - row_i + 1;
  int  temp_elem;
  int  rownum;
  int  running_offset;
  int  new_insert_pos;

  list_t* symm_entries;    /* store list of symmetric entries to add */
  int* all_rowptr;
  int len_extra_symm;   /* # of extra entries due to symmetry */
  fpos_t save_pos;

  dlist_t* symm_vals;
  fpos_t val_save_pos;
  FILE*  val_in_file;
  char val_line[BUFSIZ];
  int val_col;
  int val_ind;
  int val_i;
  int val_skip_lines;
  char* val_ThisElement;
  double val_temp_elem;

  in_file = fopen( filename, "r");
  assert( in_file != NULL );

  readHB_header(in_file, Title, Key, Type, &Nrow, &Ncol, &Nnzero, &Nrhs,
                Ptrfmt, Indfmt, Valfmt, Rhsfmt,
                &Ptrcrd, &Indcrd, &Valcrd, &Rhscrd, Rhstype);

  assert( Nrow == Ncol );
  assert( Type[0] == 'R' || Type[0] == 'r' );
  assert( Type[1] == 'S' || Type[1] == 's' );
  assert( Type[2] == 'A' || Type[2] == 'a' );

  /*  Parse the array input formats from Line 3 of HB file  */
  ParseIfmt(Ptrfmt,&Ptrperline,&Ptrwidth);
  ParseIfmt(Indfmt,&Indperline,&Indwidth);
  ParseRfmt(Valfmt,&Valperline,&Valwidth,&Valprec,&Valflag);

  /*  Read row pointer array:   */
  offset = 1;

  rowptr = (int *)malloc( sizeof(int)*(nr + 1) );
  *p_rowptr = rowptr;
  if( rowptr == NULL )
    IOHBTerminate( "Out of memory allocating row pointer" );

  all_rowptr = (int *)malloc( sizeof(int)*(row_f+2) );
  if( all_rowptr == NULL )
    IOHBTerminate( "Out of memory allocating all row pointer" );

  symm_entries = (list_t *)malloc( sizeof(list_t)*(row_f+1) );
  symm_vals = (dlist_t *)malloc( sizeof(dlist_t)*(row_f+1) );
  if( symm_entries == NULL || symm_vals == NULL )
    IOHBTerminate( "Out of memory allocating symmetric entries" );
  for( i = 0; i < (row_f+1); i++ ) {
    lst_init( &(symm_entries[i]) );
    dlst_init( &(symm_vals[i]) );
  }

  ThisElement = (char *) malloc(Ptrwidth+1);
  if ( ThisElement == NULL )
    IOHBTerminate("Insufficient memory for ThisElement (1).");
  *(ThisElement+Ptrwidth) = (char) NULL;
  count = 0;
  for( i = 0; i < Ptrcrd; i++ ) {
    fgets( line, BUFSIZ, in_file );
    if ( sscanf(line, "%*s") < 0 ) 
      IOHBTerminate("--- Null (or blank) line in ptr data region ---\n");
    col = 0;
    for( ind = 0; ind < Ptrperline; ind++ ) {

      if( count > Ncol || count > row_f+1 )
        break;

      /* copy and convert index */
      strncpy( ThisElement, line+col, Ptrwidth );
      temp_elem = atoi(ThisElement) - offset;

      if( count >= row_i ) {
        /* only save elements in the proper range for this processor */
        rowptr[ count - row_i ] = temp_elem;
      }

      all_rowptr[ count ] = temp_elem;

      count++;
      col += Ptrwidth;
    }
  }
  free(ThisElement);

#ifndef NDEBUG_IO
fprintf( stderr, "printing rowptr...\n" );
for( i = 0; i <= nr; i++ )
  fprintf( stderr, "rowptr[%d]==%d\n", i, rowptr[i] );
fprintf( stderr, "printing all_rowptr...\n" );
for( i = 0; i <= row_f+1; i++ )
  fprintf( stderr, "all_rowptr[%d]==%d\n", i, all_rowptr[i] );
#endif


  /* alloc space for column indices and values */

  ThisElement = (char *) malloc(Indwidth+1);
  if ( ThisElement == NULL )
    IOHBTerminate("Insufficient memory for ThisElement (2).");
  *(ThisElement+Indwidth) = (char) NULL;
  val_ThisElement = (char *) malloc(Valwidth+2);
  if ( val_ThisElement == NULL )
    IOHBTerminate("Insufficient memory for val_ThisElement (2).");
  *(val_ThisElement+Valwidth) = (char) NULL;
  *(val_ThisElement+Valwidth+1) = (char) NULL;

  len_extra_symm = 0;
  fgetpos( in_file, &save_pos );
  rownum = 0;

  /* position at analogous place in file for values */
  val_in_file = fopen( filename, "r" );
  assert( val_in_file != NULL );
  val_skip_lines = 4 + (Rhscrd > 0) + Ptrcrd + Indcrd;

#ifndef NDEBUG_IO
fprintf( stderr, "header lines: %d (%d), ptr lines: %d, ind lines: %d\n",
         4 + (Rhscrd>0), Rhscrd, Ptrcrd, Indcrd );
fprintf( stderr, "skipping %d lines to get to vals...\n", val_skip_lines );
#endif

  for( i = 0; i < val_skip_lines; i++ ) {
    fgets( line, BUFSIZ, val_in_file );
  }
  fgetpos( val_in_file, &val_save_pos );

  count = 0;
  /*  for( i = 0; i < Indcrd; i++ ) {*/
  i = 0;       /* line number */
  col = 0;     /* column number on a given line */
  ind = 0;     /* item number on a given line */
  val_col = 0; /* analogous */
  val_ind = 0;
  val_i = 0;
  while( i <= Indcrd ) {

    /* read new lines, if necessary */
    if( (ind % Indperline) == 0 ) {
      fgets( line, BUFSIZ, in_file );
      if ( sscanf(line,"%*s") < 0 )
        IOHBTerminate("--- Null (or blank) line in index data region ---\n");
      i++;

      col = 0;
    }

    if( (val_ind % Valperline) == 0 ) {
      fgets( val_line, BUFSIZ, val_in_file );
      if( sscanf(val_line, "%*s") < 0 )
        IOHBTerminate("--- Null (or blank) line in value region ---\n");
      val_i++;

      val_col = 0;

      if( Valflag == 'D' ) {
        while( strchr(val_line, 'D') ) *strchr(val_line,'D') = 'E';
      }
    }

    if (count == Nnzero) break;

    /* read an entry from this line */
    strncpy( ThisElement, line+col, Indwidth );
    col += Indwidth;
    ind++;

    strncpy( val_ThisElement, val_line + val_col, Valwidth );
    *(val_ThisElement+Valwidth) = (char) NULL;
    val_col += Valwidth;
    val_ind++;
    if ( Valflag != 'F' && strchr(val_ThisElement,'E') == NULL ) {
      /* insert a char prefix for exp */
      last = strlen(val_ThisElement);
      for (j=last+1;j>=0;j--) {
        val_ThisElement[j] = val_ThisElement[j-1];
        if ( val_ThisElement[j] == '+' || val_ThisElement[j] == '-' ) {
          val_ThisElement[j-1] = Valflag;
          break;
        }
      }
    }

    /* done */
    if( count >= rowptr[nr] )
      break;

    temp_elem = atoi( ThisElement ) - offset;
    val_temp_elem = atof( val_ThisElement );

#ifndef NDEBUG_IO
    fprintf( stderr, "found: %d (%f)\n", temp_elem, val_temp_elem );
#endif

    if( temp_elem >= row_i && temp_elem <= row_f ) {
      if( temp_elem != rownum ) { /* ignore diagonal entry */

#ifndef NDEBUG_IO
        fprintf( stderr, "new entry: (%d, %d) == %f\n",
                 temp_elem, rownum, val_temp_elem );
#endif

        len_extra_symm++;
        lst_insert( &(symm_entries[temp_elem]), rownum );
        dlst_insert( &(symm_vals[temp_elem]), val_temp_elem );
      }
    }

    count++;
    if( count >= all_rowptr[rownum+1] )
      rownum++;
  }


#ifndef NDEBUG_IO
fprintf( stderr, "extra entries due to symmetry: %d\n", len_extra_symm );
#endif

  len_colind = rowptr[nr] - rowptr[0] + len_extra_symm;
  *p_nnz = len_colind;
  colind = (int *)malloc( sizeof(int)*len_colind );
  *p_colind = colind;

#ifndef NDEBUG_IO
fprintf( stderr, "nnz == %d\n", len_colind );
#endif

  val = (double *)malloc( sizeof(double)*len_colind );
  *p_val = val;

  assert( colind != NULL && val != NULL );

  /*  Read column index array:  */
  fsetpos( in_file, &save_pos );
  i = 0;
  col = 0;
  ind = 0;

  fsetpos( val_in_file, &val_save_pos );
  val_i = 0;
  val_col = 0;
  val_ind = 0;

  count = 0;
  rownum = 0;
  running_offset = 0;

  while( i <= Indcrd ) {

    /* read new lines, if necessary */
    if( (ind % Indperline) == 0 ) {
      fgets( line, BUFSIZ, in_file );
      if ( sscanf(line,"%*s") < 0 )
        IOHBTerminate("--- Null (or blank) line in index data region ---\n");
      i++;

      col = 0;
    }

    if( (val_ind % Valperline) == 0 ) {
      fgets( val_line, BUFSIZ, val_in_file );
      if( sscanf(val_line, "%*s") < 0 )
        IOHBTerminate("--- Null (or blank) line in value region ---\n");
      val_i++;

      val_col = 0;

      if( Valflag == 'D' ) {
        while( strchr(val_line, 'D') ) *strchr(val_line,'D') = 'E';
      }
    }


    if (count == Nnzero) break;


    /* read an entry from this line */
    strncpy( ThisElement, line+col, Indwidth );
    col += Indwidth;
    ind++;

    strncpy( val_ThisElement, val_line + val_col, Valwidth );
    *(val_ThisElement+Valwidth) = (char) NULL;
    val_col += Valwidth;
    val_ind++;
    if ( Valflag != 'F' && strchr(val_ThisElement,'E') == NULL ) {
      /* insert a char prefix for exp */
      last = strlen(val_ThisElement);
      for (j=last+1;j>=0;j--) {
        val_ThisElement[j] = val_ThisElement[j-1];
        if ( val_ThisElement[j] == '+' || val_ThisElement[j] == '-' ) {
          val_ThisElement[j-1] = Valflag;
          break;
        }
      }
    }

    /* done */
    if( count >= all_rowptr[nr + row_i] )
      break;

    temp_elem = atoi( ThisElement ) - offset;
    val_temp_elem = atof( val_ThisElement );

#ifndef NDEBUG_IO
    fprintf( stderr, "entry: (%d, %d) == %f\n", rownum, temp_elem, val_temp_elem );
#endif

    if( count >= all_rowptr[ row_i ] ) {
      new_insert_pos = count - all_rowptr[row_i] + running_offset;

#ifndef NDEBUG_IO
      fprintf( stderr, "inserting into colind[%d]: %d\n",
               new_insert_pos, temp_elem );
#endif
      colind[ new_insert_pos ] = temp_elem;
      val[ new_insert_pos ] = val_temp_elem;
    }

    count++;
    if( count >= all_rowptr[rownum+1] ) {
      rownum++;

      if( rownum >= row_i && rownum <= row_f+1 ) {
#ifndef NDEBUG_IO
        fprintf( stderr, "rowptr[%d] (== %d) += %d\n", rownum - row_i, rowptr[ rownum - row_i ], running_offset );
#endif
        rowptr[ rownum - row_i ] += running_offset;
      }

      if( rownum >= row_i && rownum <= row_f ) {
        /* insert symmetric entries, if any */
        int new_additions = 0;
        list_node_t* trace = symm_entries[rownum].head;
        dlist_node_t* dtrace = symm_vals[rownum].head;

#ifndef NDEBUG_IO
        fprintf( stderr, "symm_entry[%d].length == %d\n", rownum, symm_entries[rownum].length );
#endif

        new_insert_pos = count - all_rowptr[row_i] + running_offset;
        while( trace != NULL ) {
          assert( dtrace != NULL );

#ifndef NDEBUG_IO
          fprintf( stderr, "inserting symmetric entry: colind[%d] = %d\n",
                   new_insert_pos + new_additions, trace->value );
          fprintf( stderr, "inserting symmetric value: val[%d] = %f\n",
                   new_insert_pos + new_additions, dtrace->value );
#endif
          colind[ new_insert_pos + new_additions ] = trace->value;
          val[ new_insert_pos + new_additions ] = dtrace->value;
          trace = trace->next;
          dtrace = dtrace->next;
          new_additions++;
        } /* while */
        assert( new_additions == symm_entries[rownum].length );
        assert( new_additions == symm_vals[rownum].length );
        running_offset += new_additions;
      } /* rownum >= row_i ... */
    } /* count >= ... */
  }

  free(ThisElement);
  free(val_ThisElement);


  for( i = 0; i < row_f+1; i++ ) {
    lst_destroy( &(symm_entries[i]) );
  }
  for( i = 0; i < row_f+1; i++ ) {
    dlst_destroy( &(symm_vals[i]) );
  }
  free( symm_entries );
  free( symm_vals );
  free( all_rowptr );

  fclose( in_file );
  fclose( val_in_file );
  return 1;
}