Logo Search packages:      
Sourcecode: dballe version File versions

dba_err dba_record_var_set_direct ( dba_record  rec,
dba_var  var 
)

Set the value of a parameter, from a dba_var.

Parameters:
rec The record where the value is to be set.
var A the dba_var with the parameter which will be copied inside the record. The record will copy the variable and will not take ownership of it: memory management will remain in charge of the caller.
Returns:
The error indicator for the function (
See also:
dba_err).

Definition at line 603 of file dba_record.c.

References DBA_RUN_OR_RETURN.

{
      dba_item i;
      dba_varcode varcode = dba_var_code(var);

      assert_is_dba_record(rec);

      /* If var is undef, remove this variable from the record */
      if (dba_var_value(var) == NULL)
      {
            dba_record_remove_item(rec, varcode);
      } else {
            /* Lookup the variable in the hash table */
            DBA_RUN_OR_RETURN(dba_record_obtain_item(rec, varcode, &i));

            /* Set the value of the variable */
            if (i->var != NULL)
            {
                  dba_var_delete(i->var);
                  i->var = NULL;
            }
            DBA_RUN_OR_RETURN(dba_var_copy(var, &(i->var)));
      }
      return dba_error_ok();
}


Generated by  Doxygen 1.6.0   Back to index