Skip to content

Commit

Permalink
[acc] removed old workaround multiple int2str() in acc_extra
Browse files Browse the repository at this point in the history
Since 2.3 we actually do not need this, as each acc_extra is individually set into its own buffer.
Related to 6c0b37f
  • Loading branch information
bogdan-iancu committed May 3, 2023
1 parent 1ec041d commit 54b03a1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
28 changes: 2 additions & 26 deletions modules/acc/acc_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,9 @@ extern tag_t* leg_tags;

static const str tag_delim = str_init("->");

/* here we copy the strings returned by int2str (which uses a static buffer) */
static char int_buf[MAX_ACC_BUFS][INT2STR_MAX_LEN*MAX_ACC_INT_BUF];

static char* static_detector[2] = {NULL,NULL};

typedef struct acc_extra** (*str2bkend)(str*);


void init_acc_extra(void)
{
int i;
/* ugly trick to get the address of the static buffer */
static_detector[0] = int2str( (unsigned long)3, &i) + i;
/* remember directly the static buffer returned by ip_addr2a()*/
static_detector[1] = _ip_addr_A_buffs[0];
}


/*
* insert a tag int the tags vector
* @param tag to insert(str value)
Expand Down Expand Up @@ -528,14 +513,13 @@ int extra2int( struct acc_extra *extra, int *attrs )
int extra2strar( extra_value_t* values, str *val_arr, int idx)
{
int n;
int r;

if (idx < 0 || idx > MAX_ACC_BUFS-2 /* last one is for legs */) {
LM_ERR("Invalid buffer index %d - maximum %d\n", idx, MAX_ACC_BUFS-2);
return 0;
}

for( n=0,r=0 ; n < extra_tgs_len ; n++) {
for( n=0 ; n < extra_tgs_len ; n++) {
/* get the value */
/* check for overflow */
if (n==MAX_ACC_EXTRA) {
Expand All @@ -549,15 +533,7 @@ int extra2strar( extra_value_t* values, str *val_arr, int idx)
val_arr[n].len = 0;
} else {
/* set the value into the acc buffer */
if (values[n].value.s+values[n].value.len==static_detector[0] ||
values[n].value.s==static_detector[1]) {
val_arr[n].s = int_buf[idx] + r*INT2STR_MAX_LEN;
val_arr[n].len = values[n].value.len;
memcpy(val_arr[n].s, values[n].value.s, values[n].value.len);
r++;
} else {
val_arr[n] = values[n].value;
}
val_arr[n] = values[n].value;
}
}

Expand Down
2 changes: 0 additions & 2 deletions modules/acc/acc_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ typedef str tag_t;
#define MAX_ACC_BUFS 3


void init_acc_extra();

int parse_acc_extra(modparam_t type, void* val);

int build_acc_extra_array(int tags_len, extra_value_t** array_p);
Expand Down
3 changes: 0 additions & 3 deletions modules/acc/acc_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,6 @@ static int mod_init( void )
}
}

/* init the extra engine */
init_acc_extra();

/* ----------- SYSLOG INIT SECTION ----------- */
acc_log_init();

Expand Down

0 comments on commit 54b03a1

Please sign in to comment.