LockRes();
for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) {
if (strcmp(counter->name(), buf) == 0) {
- Dmsg2(100, "Counter=%s val=%d\n", buf, counter->CurrentValue);
+ Dmsg3(100, "Counter=%s val=%d var_index=%d\n", buf, counter->CurrentValue, var_index);
/* -1 => return size of array */
if (var_index == -1) {
bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue);
*val_len = bsnprintf(buf, sizeof(buf), "%d", strlen(buf));
- *val_ptr = buf;
- *val_size = 0; /* don't try to free val_ptr */
+ *val_ptr = bstrdup(buf);
+ *val_size = *val_len+1;
return VAR_OK;
} else {
bsnprintf(buf, sizeof(buf), "%d", counter->CurrentValue);
len = count; /* else return # array items */
}
*val_len = bsnprintf(buf, sizeof(buf), "%d", len);
- *val_ptr = buf;
- *val_size = 0; /* don't try to free val_ptr */
+ *val_ptr = bstrdup(buf);
+ *val_size = *val_len+1;
return VAR_OK;
}
const char *var_ptr, int var_len, int var_inc, int var_idx,
const char **val_ptr, int *val_len, int *val_size)
{
- char buf[1];
int rc;
/* pass through to original callback */
This trick here allows it to determine this case. */
if (ctx->rel_lookup_flag && rc == VAR_ERR_UNDEFINED_VARIABLE) {
ctx->rel_lookup_cnt--;
- buf[0] = EOS;
- /* ****FIXME**** passing back stack variable!!! */
- *val_ptr = buf;
+ *val_ptr = bstrdup("");
*val_len = 0;
- *val_size = 0;
+ *val_size = 1;
return VAR_OK;
}