git: 9aff84db2839 - main - sysutils/LPRng: remove needless sbrk use

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Fri, 08 Dec 2023 23:31:05 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9aff84db283960642a10347a0e531226ff76466e

commit 9aff84db283960642a10347a0e531226ff76466e
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-12-08 20:02:23 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-12-08 23:29:39 +0000

    sysutils/LPRng: remove needless sbrk use
    
    Move malloc_area global under defined(DEMALLOC) which contains all
    consumers.  Delete unused Brk_check_size function.
---
 sysutils/LPRng/Makefile                            |  5 +----
 sysutils/LPRng/files/patch-src__common__lpd.c      | 25 ++++++++++++++++++++--
 sysutils/LPRng/files/patch-src_common_utilities.c  | 25 ++++++++++++++++++++++
 sysutils/LPRng/files/patch-src_include_utilities.h | 10 +++++++++
 4 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/sysutils/LPRng/Makefile b/sysutils/LPRng/Makefile
index c822adc90691..36ae870cb4bb 100644
--- a/sysutils/LPRng/Makefile
+++ b/sysutils/LPRng/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	LPRng
 PORTVERSION=	3.8.C
-PORTREVISION=	5
+PORTREVISION=	6
 PORTEPOCH=	1
 CATEGORIES=	sysutils print
 MASTER_SITES=	SF/${PORTNAME:tl}/${PORTNAME:tl}
@@ -13,9 +13,6 @@ WWW=		https://lprng.sourceforge.net/
 LICENSE=	ART10 GPLv2
 LICENSE_COMB=	dual
 
-BROKEN_aarch64=	Fails to link: missing sbrk
-BROKEN_riscv64=	Fails to link: missing sbrk
-
 LIB_DEPENDS=	libgdbm.so:databases/gdbm
 
 USES=		gmake ssl
diff --git a/sysutils/LPRng/files/patch-src__common__lpd.c b/sysutils/LPRng/files/patch-src__common__lpd.c
index d04b67598230..2ac7b2462566 100644
--- a/sysutils/LPRng/files/patch-src__common__lpd.c
+++ b/sysutils/LPRng/files/patch-src__common__lpd.c
@@ -1,6 +1,27 @@
 --- src/common/lpd.c.orig
 +++ src/common/lpd.c
-@@ -979,7 +979,6 @@
+@@ -64,7 +64,9 @@
+  *
+  ****************************************************************************/
+ 
++#ifdef DMALLOC
+ 	static char *malloc_area;
++#endif
+ 
+ int main(int argc, char *argv[], char *envp[])
+ {
+@@ -359,9 +361,9 @@
+ 		first_scan = 0;
+ 	}
+ 
++#ifdef DMALLOC
+ 	malloc_area = sbrk(0);
+ 
+-#ifdef DMALLOC
+ 	DEBUG1( "lpd: LOOP START - sbrk 0x%lx", (long)malloc_area );
+ 	{
+ 		extern int dmalloc_outfile_fd;
+@@ -979,7 +981,6 @@
  * libwrap/tcp_wrappers:
  * draht@suse.de, Mon Jan 28 2002
  */
@@ -8,7 +29,7 @@
  			struct request_info wrap_req;
  
  			request_init(&wrap_req, RQ_DAEMON, "lpd" , RQ_FILE, newsock, NULL);
-@@ -993,7 +992,6 @@
+@@ -993,7 +994,6 @@
  				close( newsock );
  				return;
  			}
diff --git a/sysutils/LPRng/files/patch-src_common_utilities.c b/sysutils/LPRng/files/patch-src_common_utilities.c
new file mode 100644
index 000000000000..553042f6d6fe
--- /dev/null
+++ b/sysutils/LPRng/files/patch-src_common_utilities.c
@@ -0,0 +1,25 @@
+--- src/common/utilities.c.orig
++++ src/common/utilities.c
+@@ -600,22 +600,6 @@
+ 	return( n );
+ }
+ 
+-
+-char *Brk_check_size( void )
+-{
+-	static char b[128];
+-	static char* Top_of_mem;	/* top of allocated memory */
+-	char *s = sbrk(0);
+-	int   v = s - Top_of_mem;
+-	if( Top_of_mem == 0 ){
+-		plp_snprintf(b, sizeof(b), "BRK: initial value 0x%lx", Cast_ptr_to_long(s) );
+-	} else {
+-		plp_snprintf(b, sizeof(b), "BRK: new value 0x%lx, increment %d", Cast_ptr_to_long(s), v );
+-	}
+-	Top_of_mem = s;
+-	return(b);
+-}
+-
+ char *mystrncat( char *s1, const char *s2, int len )
+ {
+ 	int size;
diff --git a/sysutils/LPRng/files/patch-src_include_utilities.h b/sysutils/LPRng/files/patch-src_include_utilities.h
new file mode 100644
index 000000000000..cbeacfeac350
--- /dev/null
+++ b/sysutils/LPRng/files/patch-src_include_utilities.h
@@ -0,0 +1,10 @@
+--- src/include/utilities.h.orig
++++ src/include/utilities.h
+@@ -54,7 +54,6 @@
+ int plp_sleep( int i );
+ int Get_max_servers( void );
+ int Get_max_fd( void );
+-char *Brk_check_size( void );
+ char *mystrncat( char *s1, const char *s2, int len );
+ char *mystrncpy( char *s1, const char *s2, int len );
+ int Get_nonblock_io( int fd );