Kaynağa Gözat

uid_domain: convert to memory logging helper

Henning Westerholt 5 yıl önce
ebeveyn
işleme
cf489648cf

+ 6 - 4
src/modules/uid_domain/domain.c

@@ -78,7 +78,8 @@ static int domain_add(domain_t* d, str* domain, unsigned int flags)
 	d->n++;
 	d->n++;
 	return 0;
 	return 0;
 
 
- error:
+error:
+	SHM_MEM_ERROR;
 	ERR("Unable to add new domain name (out of memory)\n");
 	ERR("Unable to add new domain name (out of memory)\n");
 	if (dom.s) shm_free(dom.s);
 	if (dom.s) shm_free(dom.s);
 	return -1;
 	return -1;
@@ -145,7 +146,8 @@ static domain_t* new_domain(str* did, str* domain, unsigned int flags)
 
 
 	return d;
 	return d;
 
 
- error:
+error:
+	SHM_MEM_ERROR;
 	ERR("Unable to create new domain structure\n");
 	ERR("Unable to create new domain structure\n");
 	free_domain(d);
 	free_domain(d);
 	return 0;
 	return 0;
@@ -355,7 +357,7 @@ int db_get_did(str* did, str* domain)
 			} else {
 			} else {
 				did->s = pkg_malloc(rec->fld[0].v.lstr.len);
 				did->s = pkg_malloc(rec->fld[0].v.lstr.len);
 				if (!did->s) {
 				if (!did->s) {
-					ERR("No memory left\n");
+					PKG_MEM_ERROR;
 					goto err;
 					goto err;
 				}
 				}
 				memcpy(did->s, rec->fld[0].v.lstr.s, rec->fld[0].v.lstr.len);
 				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);
 	tmp.s = pkg_malloc(domain->len);
 	if (!tmp.s) {
 	if (!tmp.s) {
-		ERR("No memory left\n");
+		PKG_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memcpy(tmp.s, domain->s, domain->len);
 	memcpy(tmp.s, domain->s, domain->len);

+ 1 - 1
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));
 	e = (struct hash_entry*)shm_malloc(sizeof(struct hash_entry));
 	if (!e) {
 	if (!e) {
-		ERR("Not enough memory left\n");
+		SHM_MEM_ERROR;
 		return 0;
 		return 0;
 	}
 	}
 	e->key = *key;
 	e->key = *key;

+ 3 - 3
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*));
 	domains_2 = (domain_t**)shm_malloc(sizeof(domain_t*));
 
 
 	if (!hash_1 || !hash_2 || !active_hash || !domains_1 || !domains_2) {
 	if (!hash_1 || !hash_2 || !active_hash || !domains_1 || !domains_2) {
-		ERR("No memory left\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memset(hash_1, 0, sizeof(struct hash_entry*) * HASH_SIZE);
 	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);
 	tmp.s = pkg_malloc(domain.len);
 	if (!tmp.s) {
 	if (!tmp.s) {
-		ERR("No memory left\n");
+		PKG_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memcpy(tmp.s, domain.s, domain.len);
 	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);
 	tmp.s = pkg_malloc(domain->len);
 	if (!tmp.s) {
 	if (!tmp.s) {
-		ERR("No memory left\n");
+		PKG_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	memcpy(tmp.s, domain->s, domain->len);
 	memcpy(tmp.s, domain->s, domain->len);