Module: kamailio Branch: master Commit: cf489648cfb957c49bd256e8d029fb949984673b URL: https://github.com/kamailio/kamailio/commit/cf489648cfb957c49bd256e8d029fb94...
Author: Henning Westerholt hw@skalatan.de Committer: Henning Westerholt hw@skalatan.de Date: 2020-02-13T23:08:35+01:00
uid_domain: convert to memory logging helper
---
Modified: src/modules/uid_domain/domain.c Modified: src/modules/uid_domain/hash.c Modified: src/modules/uid_domain/uid_domain_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/cf489648cfb957c49bd256e8d029fb94... Patch: https://github.com/kamailio/kamailio/commit/cf489648cfb957c49bd256e8d029fb94...
---
diff --git a/src/modules/uid_domain/domain.c b/src/modules/uid_domain/domain.c index 0c4332a106..3fe1d62676 100644 --- a/src/modules/uid_domain/domain.c +++ b/src/modules/uid_domain/domain.c @@ -78,7 +78,8 @@ static int domain_add(domain_t* d, str* domain, unsigned int flags) d->n++; return 0;
- error: +error: + SHM_MEM_ERROR; ERR("Unable to add new domain name (out of memory)\n"); if (dom.s) shm_free(dom.s); return -1; @@ -145,7 +146,8 @@ static domain_t* new_domain(str* did, str* domain, unsigned int flags)
return d;
- error: +error: + SHM_MEM_ERROR; ERR("Unable to create new domain structure\n"); free_domain(d); return 0; @@ -355,7 +357,7 @@ int db_get_did(str* did, str* domain) } else { did->s = pkg_malloc(rec->fld[0].v.lstr.len); if (!did->s) { - ERR("No memory left\n"); + PKG_MEM_ERROR; goto err; } memcpy(did->s, rec->fld[0].v.lstr.s, rec->fld[0].v.lstr.len); @@ -389,7 +391,7 @@ int is_domain_local(str* domain) */ tmp.s = pkg_malloc(domain->len); if (!tmp.s) { - ERR("No memory left\n"); + PKG_MEM_ERROR; return -1; } memcpy(tmp.s, domain->s, domain->len); diff --git a/src/modules/uid_domain/hash.c b/src/modules/uid_domain/hash.c index 5ae24d62a0..15b447076e 100644 --- a/src/modules/uid_domain/hash.c +++ b/src/modules/uid_domain/hash.c @@ -64,7 +64,7 @@ static struct hash_entry* new_hash_entry(str* key, domain_t* domain)
e = (struct hash_entry*)shm_malloc(sizeof(struct hash_entry)); if (!e) { - ERR("Not enough memory left\n"); + SHM_MEM_ERROR; return 0; } e->key = *key; diff --git a/src/modules/uid_domain/uid_domain_mod.c b/src/modules/uid_domain/uid_domain_mod.c index a261904588..fb96b906df 100644 --- a/src/modules/uid_domain/uid_domain_mod.c +++ b/src/modules/uid_domain/uid_domain_mod.c @@ -245,7 +245,7 @@ static int allocate_tables(void) domains_2 = (domain_t**)shm_malloc(sizeof(domain_t*));
if (!hash_1 || !hash_2 || !active_hash || !domains_1 || !domains_2) { - ERR("No memory left\n"); + SHM_MEM_ERROR; return -1; } memset(hash_1, 0, sizeof(struct hash_entry*) * HASH_SIZE); @@ -444,7 +444,7 @@ static int lookup_domain(struct sip_msg* msg, char* flags, char* fp)
tmp.s = pkg_malloc(domain.len); if (!tmp.s) { - ERR("No memory left\n"); + PKG_MEM_ERROR; return -1; } memcpy(tmp.s, domain.s, domain.len); @@ -480,7 +480,7 @@ static int get_did(str* did, str* domain)
tmp.s = pkg_malloc(domain->len); if (!tmp.s) { - ERR("No memory left\n"); + PKG_MEM_ERROR; return -1; } memcpy(tmp.s, domain->s, domain->len);