static int function_sampleadd(value_t *valuep, value_t args);

const struct function functions_ext[] = {
  { "SAMPLEADD", NULL, 0, function_sampleadd, 0 },
  { NULL       , NULL, 0, NULL              , 0 }
};

static int function_sampleadd(value_t *valuep, value_t args)
{
  int r, result;
  integer_t integer1 = 0, integer2 = 0;

  if (args) {
    if ((r = value_get_integer(args, &integer1)) < 0)
      ;
    args = args->next;
  }

  if (args) {
    if ((r = value_get_integer(args, &integer2)) < 0)
      ;
  }

  result = integer1 + integer2;

  if ((r = value_extend_value(valuep)) < 0)
    return r;
  if ((r = value_set_integer(*valuep, result)) < 0)
    return r;
  valuep = &(*valuep)->next;

  if ((r = value_shrink_value(valuep)) < 0)
    return r;

  return 0;
}
