Browse code

uid_domain: convert to memory logging helper

Henning Westerholt authored on 13/02/2020 21:37:46
Showing 3 changed files
... ...
@@ -78,7 +78,8 @@ static int domain_add(domain_t* d, str* domain, unsigned int flags)
78 78
 	d->n++;
79 79
 	return 0;
80 80
 
81
- error:
81
+error:
82
+	SHM_MEM_ERROR;
82 83
 	ERR("Unable to add new domain name (out of memory)\n");
83 84
 	if (dom.s) shm_free(dom.s);
84 85
 	return -1;
... ...
@@ -145,7 +146,8 @@ static domain_t* new_domain(str* did, str* domain, unsigned int flags)
145 145
 
146 146
 	return d;
147 147
 
148
- error:
148
+error:
149
+	SHM_MEM_ERROR;
149 150
 	ERR("Unable to create new domain structure\n");
150 151
 	free_domain(d);
151 152
 	return 0;
... ...
@@ -355,7 +357,7 @@ int db_get_did(str* did, str* domain)
355 355
 			} else {
356 356
 				did->s = pkg_malloc(rec->fld[0].v.lstr.len);
357 357
 				if (!did->s) {
358
-					ERR("No memory left\n");
358
+					PKG_MEM_ERROR;
359 359
 					goto err;
360 360
 				}
361 361
 				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)
389 389
 	 */
390 390
 	tmp.s = pkg_malloc(domain->len);
391 391
 	if (!tmp.s) {
392
-		ERR("No memory left\n");
392
+		PKG_MEM_ERROR;
393 393
 		return -1;
394 394
 	}
395 395
 	memcpy(tmp.s, domain->s, domain->len);
... ...
@@ -64,7 +64,7 @@ static struct hash_entry* new_hash_entry(str* key, domain_t* domain)
64 64
 
65 65
 	e = (struct hash_entry*)shm_malloc(sizeof(struct hash_entry));
66 66
 	if (!e) {
67
-		ERR("Not enough memory left\n");
67
+		SHM_MEM_ERROR;
68 68
 		return 0;
69 69
 	}
70 70
 	e->key = *key;
... ...
@@ -245,7 +245,7 @@ static int allocate_tables(void)
245 245
 	domains_2 = (domain_t**)shm_malloc(sizeof(domain_t*));
246 246
 
247 247
 	if (!hash_1 || !hash_2 || !active_hash || !domains_1 || !domains_2) {
248
-		ERR("No memory left\n");
248
+		SHM_MEM_ERROR;
249 249
 		return -1;
250 250
 	}
251 251
 	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)
444 444
 
445 445
 	tmp.s = pkg_malloc(domain.len);
446 446
 	if (!tmp.s) {
447
-		ERR("No memory left\n");
447
+		PKG_MEM_ERROR;
448 448
 		return -1;
449 449
 	}
450 450
 	memcpy(tmp.s, domain.s, domain.len);
... ...
@@ -480,7 +480,7 @@ static int get_did(str* did, str* domain)
480 480
 
481 481
 	tmp.s = pkg_malloc(domain->len);
482 482
 	if (!tmp.s) {
483
-		ERR("No memory left\n");
483
+		PKG_MEM_ERROR;
484 484
 		return -1;
485 485
 	}
486 486
 	memcpy(tmp.s, domain->s, domain->len);