diff --git a/src/modules/lcr/hash.c b/src/modules/lcr/hash.c index 8dd922f7617..d49fb666af6 100644 --- a/src/modules/lcr/hash.c +++ b/src/modules/lcr/hash.c @@ -48,7 +48,7 @@ int rule_hash_table_insert(struct rule_info **hash_table, unsigned int lcr_id, rule = (struct rule_info *)shm_malloc(sizeof(struct rule_info)); if(rule == NULL) { - LM_ERR("no shm memory for rule hash table entry\n"); + SHM_MEM_ERROR_FMT("for rule hash table entry\n"); if(from_uri_re) shm_free(from_uri_re); if(request_uri_re) @@ -97,7 +97,12 @@ int rule_hash_table_insert(struct rule_info **hash_table, unsigned int lcr_id, /* Add rule_id info to rule_id hash table */ rid = (struct rule_id_info *)pkg_malloc(sizeof(struct rule_id_info)); if(rid == NULL) { - LM_ERR("no pkg memory for rule_id hash table entry\n"); + PKG_MEM_ERROR_FMT("for rule_id hash table entry\n"); + if(from_uri_re) + shm_free(from_uri_re); + if(request_uri_re) + shm_free(request_uri_re); + shm_free(rule); return 0; } memset(rid, 0, sizeof(struct rule_id_info)); @@ -143,7 +148,7 @@ int rule_hash_table_insert_target(struct rule_info **hash_table, target = (struct target *)shm_malloc(sizeof(struct target)); if(target == NULL) { - LM_ERR("cannot allocate memory for rule target\n"); + SHM_MEM_ERROR_FMT("for rule target\n"); return 0; } diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c index a581c0b3497..1f713a9e404 100644 --- a/src/modules/lcr/lcr_mod.c +++ b/src/modules/lcr/lcr_mod.c @@ -704,7 +704,7 @@ static int mod_init(void) rule_pt = (struct rule_info ***)shm_malloc( sizeof(struct rule_info **) * (lcr_count_param + 1)); if(rule_pt == 0) { - LM_ERR("no memory for rule hash table pointer table\n"); + SHM_MEM_ERROR_FMT("for rule hash table pointer table\n"); goto err; } memset(rule_pt, 0, sizeof(struct rule_info **) * (lcr_count_param + 1)); @@ -715,7 +715,7 @@ static int mod_init(void) rule_pt[i] = (struct rule_info **)shm_malloc( sizeof(struct rule_info *) * (lcr_rule_hash_size_param + 1)); if(rule_pt[i] == 0) { - LM_ERR("no memory for rules hash table\n"); + SHM_MEM_ERROR_FMT("for rules hash table\n"); goto err; } memset(rule_pt[i], 0, @@ -728,7 +728,7 @@ static int mod_init(void) gw_pt = (struct gw_info **)shm_malloc( sizeof(struct gw_info *) * (lcr_count_param + 1)); if(gw_pt == 0) { - LM_ERR("no memory for gw table pointer table\n"); + SHM_MEM_ERROR_FMT("for gw table pointer table\n"); goto err; } memset(gw_pt, 0, sizeof(struct gw_info *) * (lcr_count_param + 1)); @@ -742,7 +742,7 @@ static int mod_init(void) gw_pt[i] = (struct gw_info *)shm_malloc( sizeof(struct gw_info) * (lcr_gw_count_param + 1)); if(gw_pt[i] == 0) { - LM_ERR("no memory for gw table\n"); + SHM_MEM_ERROR_FMT("for gw table\n"); goto err; } memset(gw_pt[i], 0, sizeof(struct gw_info) * (lcr_gw_count_param + 1)); @@ -892,7 +892,7 @@ static pcre *reg_ex_comp(const char *pattern) result = (pcre *)shm_malloc(size); if(result == NULL) { pcre_free(re); - LM_ERR("not enough shared memory for compiled PCRE pattern\n"); + SHM_MEM_ERROR_FMT("for compiled PCRE pattern\n"); return (pcre *)0; } memcpy(result, re, size); @@ -1032,7 +1032,7 @@ static int prefix_len_insert( if(this->prefix_len < prefix_len) { lcr_rec = shm_malloc(sizeof(struct rule_info)); if(lcr_rec == NULL) { - LM_ERR("no shared memory for rule_info\n"); + SHM_MEM_ERROR_FMT("for rule_info\n"); return 0; } memset(lcr_rec, 0, sizeof(struct rule_info)); @@ -1047,7 +1047,7 @@ static int prefix_len_insert( lcr_rec = shm_malloc(sizeof(struct rule_info)); if(lcr_rec == NULL) { - LM_ERR("no shared memory for rule_info\n"); + SHM_MEM_ERROR_FMT("for rule_info\n"); return 0; } memset(lcr_rec, 0, sizeof(struct rule_info)); @@ -1451,7 +1451,7 @@ int reload_tables() rule_id_hash_table = pkg_malloc( sizeof(struct rule_id_info *) * lcr_rule_hash_size_param); if(!rule_id_hash_table) { - LM_ERR("no pkg memory for rule_id hash table\n"); + PKG_MEM_ERROR_FMT("for rule_id hash table\n"); goto err; } memset(rule_id_hash_table, 0,