Browse code

core: cleanup, remove local_malloc/local_free #define in core

- remove the unused local_malloc and local_free #define in the core
- they were introduced in 2002 and not touched in the repository since this time
- they pointed to pkg_malloc and pkg_free

Henning Westerholt authored on 23/12/2018 21:50:43
Showing 4 changed files
... ...
@@ -43,12 +43,6 @@
43 43
 
44 44
 #include "mem/mem.h"
45 45
 
46
-#ifndef local_malloc
47
-#define local_malloc pkg_malloc
48
-#endif
49
-#ifndef local_free
50
-#define local_free pkg_free
51
-#endif
52 46
 
53 47
 char* poll_support="poll"
54 48
 #ifdef HAVE_EPOLL
... ...
@@ -472,7 +466,7 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
472 466
 	h->poll_method=poll_method;
473 467
 	
474 468
 	/* common stuff, everybody has fd_hash */
475
-	h->fd_hash=local_malloc(sizeof(*(h->fd_hash))*h->max_fd_no);
469
+	h->fd_hash=pkg_malloc(sizeof(*(h->fd_hash))*h->max_fd_no);
476 470
 	if (h->fd_hash==0){
477 471
 		PKG_MEM_CRITICAL;
478 472
 		goto error;
... ...
@@ -490,7 +484,7 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
490 484
 #ifdef HAVE_DEVPOLL
491 485
 		case POLL_DEVPOLL:
492 486
 #endif
493
-			h->fd_array=local_malloc(sizeof(*(h->fd_array))*h->max_fd_no);
487
+			h->fd_array=pkg_malloc(sizeof(*(h->fd_array))*h->max_fd_no);
494 488
 			if (h->fd_array==0){
495 489
 				PKG_MEM_CRITICAL;
496 490
 				goto error;
... ...
@@ -519,7 +513,7 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
519 513
 #ifdef HAVE_EPOLL
520 514
 		case POLL_EPOLL_LT:
521 515
 		case POLL_EPOLL_ET:
522
-			h->ep_array=local_malloc(sizeof(*(h->ep_array))*h->max_fd_no);
516
+			h->ep_array=pkg_malloc(sizeof(*(h->ep_array))*h->max_fd_no);
523 517
 			if (h->ep_array==0){
524 518
 				PKG_MEM_CRITICAL;
525 519
 				goto error;
... ...
@@ -542,12 +536,12 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
542 536
 			   decrease the array size.
543 537
 			 */
544 538
 			h->kq_array_size=2 * h->max_fd_no + h->kq_changes_size;
545
-			h->kq_array=local_malloc(sizeof(*(h->kq_array))*h->kq_array_size);
539
+			h->kq_array=pkg_malloc(sizeof(*(h->kq_array))*h->kq_array_size);
546 540
 			if (h->kq_array==0){
547 541
 				PKG_MEM_CRITICAL;
548 542
 				goto error;
549 543
 			}
550
-			h->kq_changes=local_malloc(sizeof(*(h->kq_changes))*
544
+			h->kq_changes=pkg_malloc(sizeof(*(h->kq_changes))*
551 545
 										h->kq_changes_size);
552 546
 			if (h->kq_changes==0){
553 547
 				PKG_MEM_CRITICAL;
... ...
@@ -585,7 +579,7 @@ void destroy_io_wait(io_wait_h* h)
585 579
 		case POLL_EPOLL_ET:
586 580
 			destroy_epoll(h);
587 581
 			if (h->ep_array){
588
-				local_free(h->ep_array);
582
+				pkg_free(h->ep_array);
589 583
 				h->ep_array=0;
590 584
 			}
591 585
 		break;
... ...
@@ -594,11 +588,11 @@ void destroy_io_wait(io_wait_h* h)
594 588
 		case POLL_KQUEUE:
595 589
 			destroy_kqueue(h);
596 590
 			if (h->kq_array){
597
-				local_free(h->kq_array);
591
+				pkg_free(h->kq_array);
598 592
 				h->kq_array=0;
599 593
 			}
600 594
 			if (h->kq_changes){
601
-				local_free(h->kq_changes);
595
+				pkg_free(h->kq_changes);
602 596
 				h->kq_changes=0;
603 597
 			}
604 598
 			break;
... ...
@@ -617,11 +611,11 @@ void destroy_io_wait(io_wait_h* h)
617 611
 			;
618 612
 	}
619 613
 		if (h->fd_array){
620
-			local_free(h->fd_array);
614
+			pkg_free(h->fd_array);
621 615
 			h->fd_array=0;
622 616
 		}
623 617
 		if (h->fd_hash){
624
-			local_free(h->fd_hash);
618
+			pkg_free(h->fd_hash);
625 619
 			h->fd_hash=0;
626 620
 		}
627 621
 }
... ...
@@ -33,9 +33,6 @@
33 33
  *                to int). 0 has a special not set/not init. meaning
34 34
  *                (a lot of sanity checks and the sigio_rt code are based on
35 35
  *                 this assumption)
36
- *     local_malloc (defaults to pkg_malloc)
37
- *     local_free   (defaults to pkg_free)
38
- *
39 36
  */
40 37
 
41 38
 #ifndef _io_wait_h
... ...
@@ -54,9 +54,6 @@ counter_def_t dns_cnt_defs[] =  {
54 54
 	{0, 0, 0, 0, 0, 0 }
55 55
 };
56 56
 
57
-/* mallocs for local stuff */
58
-#define local_malloc pkg_malloc
59
-#define local_free   pkg_free
60 57
 
61 58
 #ifdef USE_NAPTR
62 59
 static int naptr_proto_pref[PROTO_LAST+1];
... ...
@@ -305,7 +302,7 @@ struct srv_rdata* dns_srv_parser( unsigned char* msg, unsigned char* end,
305 302
 	if (len>255)
306 303
 		goto error;
307 304
 	/* alloc enought space for the struct + null terminated name */
308
-	srv=local_malloc(sizeof(struct srv_rdata)-1+len+1);
305
+	srv=pkg_malloc(sizeof(struct srv_rdata)-1+len+1);
309 306
 	if (srv==0){
310 307
 		PKG_MEM_ERROR;
311 308
 		goto error;
... ...
@@ -319,7 +316,7 @@ struct srv_rdata* dns_srv_parser( unsigned char* msg, unsigned char* end,
319 316
 	
320 317
 	return srv;
321 318
 error:
322
-	if (srv) local_free(srv);
319
+	if (srv) pkg_free(srv);
323 320
 	return 0;
324 321
 }
325 322
 
... ...
@@ -391,7 +388,7 @@ struct naptr_rdata* dns_naptr_parser( unsigned char* msg, unsigned char* end,
391 388
 	len=strlen(repl);
392 389
 	if (len>255)
393 390
 		goto error;
394
-	naptr=local_malloc(sizeof(struct naptr_rdata)+flags_len+services_len+
391
+	naptr=pkg_malloc(sizeof(struct naptr_rdata)+flags_len+services_len+
395 392
 						regexp_len+len+1-1);
396 393
 	if (naptr == 0){
397 394
 		PKG_MEM_ERROR;
... ...
@@ -416,7 +413,7 @@ struct naptr_rdata* dns_naptr_parser( unsigned char* msg, unsigned char* end,
416 413
 	
417 414
 	return naptr;
418 415
 error:
419
-	if (naptr) local_free(naptr);
416
+	if (naptr) pkg_free(naptr);
420 417
 	return 0;
421 418
 }
422 419
 
... ...
@@ -437,7 +434,7 @@ struct cname_rdata* dns_cname_parser( unsigned char* msg, unsigned char* end,
437 434
 	if (len>255)
438 435
 		goto error;
439 436
 	/* alloc sizeof struct + space for the null terminated name */
440
-	cname=local_malloc(sizeof(struct cname_rdata)-1+len+1);
437
+	cname=pkg_malloc(sizeof(struct cname_rdata)-1+len+1);
441 438
 	if(cname==0){
442 439
 		PKG_MEM_ERROR;
443 440
 		goto error;
... ...
@@ -447,7 +444,7 @@ struct cname_rdata* dns_cname_parser( unsigned char* msg, unsigned char* end,
447 444
 	cname->name[cname->name_len]=0;
448 445
 	return cname;
449 446
 error:
450
-	if (cname) local_free(cname);
447
+	if (cname) pkg_free(cname);
451 448
 	return 0;
452 449
 }
453 450
 
... ...
@@ -461,7 +458,7 @@ struct a_rdata* dns_a_parser(unsigned char* rdata, unsigned char* eor)
461 458
 	struct a_rdata* a;
462 459
 	
463 460
 	if (rdata+4>eor) goto error;
464
-	a=(struct a_rdata*)local_malloc(sizeof(struct a_rdata));
461
+	a=(struct a_rdata*)pkg_malloc(sizeof(struct a_rdata));
465 462
 	if (a==0){
466 463
 		PKG_MEM_ERROR;
467 464
 		goto error;
... ...
@@ -481,7 +478,7 @@ struct aaaa_rdata* dns_aaaa_parser(unsigned char* rdata, unsigned char* eor)
481 478
 	struct aaaa_rdata* aaaa;
482 479
 	
483 480
 	if (rdata+16>eor) goto error;
484
-	aaaa=(struct aaaa_rdata*)local_malloc(sizeof(struct aaaa_rdata));
481
+	aaaa=(struct aaaa_rdata*)pkg_malloc(sizeof(struct aaaa_rdata));
485 482
 	if (aaaa==0){
486 483
 		PKG_MEM_ERROR;
487 484
 		goto error;
... ...
@@ -531,7 +528,7 @@ static struct txt_rdata* dns_txt_parser(unsigned char* msg, unsigned char* end,
531 528
 	}while(p<end);
532 529
 	/* alloc sizeof struct + space for the dns_cstr array + space for
533 530
 	   the strings */
534
-	txt=local_malloc(sizeof(struct txt_rdata) +(n-1)*sizeof(struct dns_cstr)+
531
+	txt=pkg_malloc(sizeof(struct txt_rdata) +(n-1)*sizeof(struct dns_cstr)+
535 532
 						str_size);
536 533
 	if(unlikely(txt==0)){
537 534
 		PKG_MEM_ERROR;
... ...
@@ -555,7 +552,7 @@ static struct txt_rdata* dns_txt_parser(unsigned char* msg, unsigned char* end,
555 552
 	}
556 553
 	return txt;
557 554
 error:
558
-	if (txt) local_free(txt);
555
+	if (txt) pkg_free(txt);
559 556
 	return 0;
560 557
 }
561 558
 
... ...
@@ -602,7 +599,7 @@ static struct ebl_rdata* dns_ebl_parser(unsigned char* msg, unsigned char* end,
602 599
 		goto error;
603 600
 	apex_len=strlen(apex);
604 601
 	/* alloc sizeof struct + space for the 2 null-terminated strings */
605
-	ebl=local_malloc(sizeof(struct ebl_rdata)-1+sep_len+1+apex_len+1);
602
+	ebl=pkg_malloc(sizeof(struct ebl_rdata)-1+sep_len+1+apex_len+1);
606 603
 	if (ebl==0){
607 604
 		PKG_MEM_ERROR;
608 605
 		goto error;
... ...
@@ -619,7 +616,7 @@ static struct ebl_rdata* dns_ebl_parser(unsigned char* msg, unsigned char* end,
619 616
 	
620 617
 	return ebl;
621 618
 error:
622
-	if (ebl) local_free(ebl);
619
+	if (ebl) pkg_free(ebl);
623 620
 	return 0;
624 621
 }
625 622
 
... ...
@@ -640,7 +637,7 @@ struct ptr_rdata* dns_ptr_parser( unsigned char* msg, unsigned char* end,
640 637
 	if (len>255)
641 638
 		goto error;
642 639
 	/* alloc sizeof struct + space for the null terminated name */
643
-	pname=local_malloc(sizeof(struct ptr_rdata)-1+len+1);
640
+	pname=pkg_malloc(sizeof(struct ptr_rdata)-1+len+1);
644 641
 	if(pname==0){
645 642
 		PKG_MEM_ERROR;
646 643
 		goto error;
... ...
@@ -650,7 +647,7 @@ struct ptr_rdata* dns_ptr_parser( unsigned char* msg, unsigned char* end,
650 647
 	pname->ptrdname[pname->ptrdname_len]=0;
651 648
 	return pname;
652 649
 error:
653
-	if (pname) local_free(pname);
650
+	if (pname) pkg_free(pname);
654 651
 	return 0;
655 652
 }
656 653
 
... ...
@@ -665,8 +662,8 @@ void free_rdata_list(struct rdata* head)
665 662
 	while (l != 0) {
666 663
 		next_l = l->next;
667 664
 		/* free the parsed rdata*/
668
-		if (l->rdata) local_free(l->rdata);
669
-		local_free(l);
665
+		if (l->rdata) pkg_free(l->rdata);
666
+		pkg_free(l);
670 667
 		l = next_l;
671 668
 	}
672 669
 }
... ...
@@ -833,7 +830,7 @@ again:
833 830
 		}
834 831
 		/* expand the "type" record  (rdata)*/
835 832
 
836
-		rd=(struct rdata*) local_malloc(sizeof(struct rdata)+rec_name_len+
833
+		rd=(struct rdata*) pkg_malloc(sizeof(struct rdata)+rec_name_len+
837 834
 										1-1);
838 835
 		if (rd==0){
839 836
 			PKG_MEM_ERROR;
... ...
@@ -972,7 +969,7 @@ again:
972 969
 	 * (queried) to long name (answered)
973 970
 	 */
974 971
 	if ((search_list_used==1)&&(fullname_rd!=0)) {
975
-		rd=(struct rdata*) local_malloc(sizeof(struct rdata)+name_len+1-1);
972
+		rd=(struct rdata*) pkg_malloc(sizeof(struct rdata)+name_len+1-1);
976 973
 		if (unlikely(rd==0)){
977 974
 			PKG_MEM_ERROR;
978 975
 			goto error;
... ...
@@ -985,7 +982,7 @@ again:
985 982
 		rd->name[name_len]=0;
986 983
 		rd->name_len=name_len;
987 984
 		/* alloc sizeof struct + space for the null terminated name */
988
-		rd->rdata=(void*)local_malloc(sizeof(struct cname_rdata)-1+
985
+		rd->rdata=(void*)pkg_malloc(sizeof(struct cname_rdata)-1+
989 986
 										head->name_len+1);
990 987
 		if(unlikely(rd->rdata==0)){
991 988
 			PKG_MEM_ERROR;
... ...
@@ -1009,7 +1006,7 @@ error_parse:
1009 1006
 				name, type,
1010 1007
 				p, end, rtype, class, ttl, rdlength);
1011 1008
 error_rd:
1012
-		if (rd) local_free(rd); /* rd->rdata=0 & rd is not linked yet into
1009
+		if (rd) pkg_free(rd); /* rd->rdata=0 & rd is not linked yet into
1013 1010
 								   the list */
1014 1011
 error:
1015 1012
 		LM_ERR("get_record\n");
... ...
@@ -100,9 +100,6 @@
100 100
 #include "ut.h"
101 101
 #include "cfg/cfg_struct.h"
102 102
 
103
-#define local_malloc pkg_malloc
104
-#define local_free   pkg_free
105
-
106 103
 #include <fcntl.h> /* must be included after io_wait.h if SIGIO_RT is used */
107 104
 
108 105