Logo Search packages:      
Sourcecode: dballe version File versions

dba_err dba_record_add ( dba_record  dest,
dba_record  source 
)

Copy all data from the record source into dest. At the end of the function, dest will contain its previous values, plus the values in source. If a value is present both in source and in dest, the one in dest will be overwritten.

Parameters:
dest The record to copy data into.
source The record to copy data from.
Returns:
The error indicator for the function.

Definition at line 266 of file dba_record.c.

References DBA_RUN_OR_RETURN.

{
      int i;
      assert_is_dba_record(dest);
      assert_is_dba_record(source);

      /* Copy the keyword table first */
      for (i = 0; i < KEYWORD_TABLE_SIZE; i++)
            if (source->keydata[i] != NULL)
            {
                  if (dest->keydata[i] != NULL)
                        free(dest->keydata[i]);
                  DBA_RUN_OR_RETURN(dba_var_copy(source->keydata[i], &(dest->keydata[i])));
            }

      /* Then the variables list */
      if (source->vars)
      {
            dba_item* t = &(dest->vars);
            dba_item c;
            for ( ; (*t) != NULL; t = &((*t)->next))
                  ;
            for (c = source->vars; c != NULL; c = c->next)
            {
                  (*t) = (dba_item)calloc(1, sizeof(struct _dba_item));
                  if ((*t) == NULL)
                        return dba_error_alloc("creating new dba_item");

                  DBA_RUN_OR_RETURN(dba_var_copy(c->var, &((*t)->var)));

                  t = &((*t)->next);
            }
      }
      return dba_error_ok();
}


Generated by  Doxygen 1.6.0   Back to index