Module: kamailio Branch: master Commit: b3e14fc9bd379ad77c13ade0bc60dc32f1d55ade URL: https://github.com/kamailio/kamailio/commit/b3e14fc9bd379ad77c13ade0bc60dc32...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-01-12T09:50:36+01:00
drouting: option to use a static structure for computing ac max val
---
Modified: src/modules/drouting/dr_time.c Modified: src/modules/drouting/dr_time.h
---
Diff: https://github.com/kamailio/kamailio/commit/b3e14fc9bd379ad77c13ade0bc60dc32... Patch: https://github.com/kamailio/kamailio/commit/b3e14fc9bd379ad77c13ade0bc60dc32...
---
diff --git a/src/modules/drouting/dr_time.c b/src/modules/drouting/dr_time.c index 879665a07d..0af2e51326 100644 --- a/src/modules/drouting/dr_time.c +++ b/src/modules/drouting/dr_time.c @@ -203,17 +203,22 @@ int ac_tm_free(ac_tm_p _atp) return 0; }
-ac_maxval_p ac_get_maxval(ac_tm_p _atp) +ac_maxval_p ac_get_maxval(ac_tm_p _atp, int mode) { struct tm _tm; int _v; ac_maxval_p _amp = NULL; + static ac_maxval_t _amv;
if(!_atp) return NULL; - _amp = (ac_maxval_p)shm_malloc(sizeof(ac_maxval_t)); - if(!_amp) - return NULL; + if(mode==1) { + _amp = (ac_maxval_p)shm_malloc(sizeof(ac_maxval_t)); + if(!_amp) + return NULL; + } else { + _amp = &_amv; + } memset(_amp, 0, sizeof(ac_maxval_t));
/* the number of the days in the year */ @@ -270,11 +275,13 @@ ac_maxval_p ac_get_maxval(ac_tm_p _atp) + 1; #endif
- if(_atp->mv!=NULL) { - shm_free(_atp->mv); - } + if(mode==1) { + if(_atp->mv!=NULL) { + shm_free(_atp->mv); + }
- _atp->mv = _amp; + _atp->mv = _amp; + } return _amp; }
@@ -1050,7 +1057,7 @@ int check_byxxx(tmrec_p _trp, ac_tm_p _atp) && !_trp->byweekno) return REC_MATCH;
- _amp = ac_get_maxval(_atp); + _amp = ac_get_maxval(_atp, 0); if(!_amp) return REC_NOMATCH;
diff --git a/src/modules/drouting/dr_time.h b/src/modules/drouting/dr_time.h index 86c041a646..67638e2358 100644 --- a/src/modules/drouting/dr_time.h +++ b/src/modules/drouting/dr_time.h @@ -76,7 +76,7 @@ int ac_tm_free(ac_tm_p);
int ac_get_mweek(struct tm *); int ac_get_yweek(struct tm *); -ac_maxval_p ac_get_maxval(ac_tm_p); +ac_maxval_p ac_get_maxval(ac_tm_p, int); int ac_get_wkst();
int ac_print(ac_tm_p);