head 1.5; access; symbols pkgsrc-2026Q1:1.5.0.108 pkgsrc-2026Q1-base:1.5 pkgsrc-2025Q4:1.5.0.106 pkgsrc-2025Q4-base:1.5 pkgsrc-2025Q3:1.5.0.104 pkgsrc-2025Q3-base:1.5 pkgsrc-2025Q2:1.5.0.102 pkgsrc-2025Q2-base:1.5 pkgsrc-2025Q1:1.5.0.100 pkgsrc-2025Q1-base:1.5 pkgsrc-2024Q4:1.5.0.98 pkgsrc-2024Q4-base:1.5 pkgsrc-2024Q3:1.5.0.96 pkgsrc-2024Q3-base:1.5 pkgsrc-2024Q2:1.5.0.94 pkgsrc-2024Q2-base:1.5 pkgsrc-2024Q1:1.5.0.92 pkgsrc-2024Q1-base:1.5 pkgsrc-2023Q4:1.5.0.90 pkgsrc-2023Q4-base:1.5 pkgsrc-2023Q3:1.5.0.88 pkgsrc-2023Q3-base:1.5 pkgsrc-2023Q2:1.5.0.86 pkgsrc-2023Q2-base:1.5 pkgsrc-2023Q1:1.5.0.84 pkgsrc-2023Q1-base:1.5 pkgsrc-2022Q4:1.5.0.82 pkgsrc-2022Q4-base:1.5 pkgsrc-2022Q3:1.5.0.80 pkgsrc-2022Q3-base:1.5 pkgsrc-2022Q2:1.5.0.78 pkgsrc-2022Q2-base:1.5 pkgsrc-2022Q1:1.5.0.76 pkgsrc-2022Q1-base:1.5 pkgsrc-2021Q4:1.5.0.74 pkgsrc-2021Q4-base:1.5 pkgsrc-2021Q3:1.5.0.72 pkgsrc-2021Q3-base:1.5 pkgsrc-2021Q2:1.5.0.70 pkgsrc-2021Q2-base:1.5 pkgsrc-2021Q1:1.5.0.68 pkgsrc-2021Q1-base:1.5 pkgsrc-2020Q4:1.5.0.66 pkgsrc-2020Q4-base:1.5 pkgsrc-2020Q3:1.5.0.64 pkgsrc-2020Q3-base:1.5 pkgsrc-2020Q2:1.5.0.60 pkgsrc-2020Q2-base:1.5 pkgsrc-2020Q1:1.5.0.40 pkgsrc-2020Q1-base:1.5 pkgsrc-2019Q4:1.5.0.62 pkgsrc-2019Q4-base:1.5 pkgsrc-2019Q3:1.5.0.58 pkgsrc-2019Q3-base:1.5 pkgsrc-2019Q2:1.5.0.56 pkgsrc-2019Q2-base:1.5 pkgsrc-2019Q1:1.5.0.54 pkgsrc-2019Q1-base:1.5 pkgsrc-2018Q4:1.5.0.52 pkgsrc-2018Q4-base:1.5 pkgsrc-2018Q3:1.5.0.50 pkgsrc-2018Q3-base:1.5 pkgsrc-2018Q2:1.5.0.48 pkgsrc-2018Q2-base:1.5 pkgsrc-2018Q1:1.5.0.46 pkgsrc-2018Q1-base:1.5 pkgsrc-2017Q4:1.5.0.44 pkgsrc-2017Q4-base:1.5 pkgsrc-2017Q3:1.5.0.42 pkgsrc-2017Q3-base:1.5 pkgsrc-2017Q2:1.5.0.38 pkgsrc-2017Q2-base:1.5 pkgsrc-2017Q1:1.5.0.36 pkgsrc-2017Q1-base:1.5 pkgsrc-2016Q4:1.5.0.34 pkgsrc-2016Q4-base:1.5 pkgsrc-2016Q3:1.5.0.32 pkgsrc-2016Q3-base:1.5 pkgsrc-2016Q2:1.5.0.30 pkgsrc-2016Q2-base:1.5 pkgsrc-2016Q1:1.5.0.28 pkgsrc-2016Q1-base:1.5 pkgsrc-2015Q4:1.5.0.26 pkgsrc-2015Q4-base:1.5 pkgsrc-2015Q3:1.5.0.24 pkgsrc-2015Q3-base:1.5 pkgsrc-2015Q2:1.5.0.22 pkgsrc-2015Q2-base:1.5 pkgsrc-2015Q1:1.5.0.20 pkgsrc-2015Q1-base:1.5 pkgsrc-2014Q4:1.5.0.18 pkgsrc-2014Q4-base:1.5 pkgsrc-2014Q3:1.5.0.16 pkgsrc-2014Q3-base:1.5 pkgsrc-2014Q2:1.5.0.14 pkgsrc-2014Q2-base:1.5 pkgsrc-2014Q1:1.5.0.12 pkgsrc-2014Q1-base:1.5 pkgsrc-2013Q4:1.5.0.10 pkgsrc-2013Q4-base:1.5 pkgsrc-2013Q3:1.5.0.8 pkgsrc-2013Q3-base:1.5 pkgsrc-2013Q2:1.5.0.6 pkgsrc-2013Q2-base:1.5 pkgsrc-2013Q1:1.5.0.4 pkgsrc-2013Q1-base:1.5 pkgsrc-2012Q4:1.5.0.2 pkgsrc-2012Q4-base:1.5 pkgsrc-2012Q3:1.4.0.54 pkgsrc-2012Q3-base:1.4 pkgsrc-2012Q2:1.4.0.52 pkgsrc-2012Q2-base:1.4 pkgsrc-2012Q1:1.4.0.50 pkgsrc-2012Q1-base:1.4 pkgsrc-2011Q4:1.4.0.48 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q3:1.4.0.46 pkgsrc-2011Q3-base:1.4 pkgsrc-2011Q2:1.4.0.44 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.4.0.42 pkgsrc-2011Q1-base:1.4 pkgsrc-2010Q4:1.4.0.40 pkgsrc-2010Q4-base:1.4 pkgsrc-2010Q3:1.4.0.38 pkgsrc-2010Q3-base:1.4 pkgsrc-2010Q2:1.4.0.36 pkgsrc-2010Q2-base:1.4 pkgsrc-2010Q1:1.4.0.34 pkgsrc-2010Q1-base:1.4 pkgsrc-2009Q4:1.4.0.32 pkgsrc-2009Q4-base:1.4 pkgsrc-2009Q3:1.4.0.30 pkgsrc-2009Q3-base:1.4 pkgsrc-2009Q2:1.4.0.28 pkgsrc-2009Q2-base:1.4 pkgsrc-2009Q1:1.4.0.26 pkgsrc-2009Q1-base:1.4 pkgsrc-2008Q4:1.4.0.24 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.22 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.20 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.18 pkgsrc-2008Q2-base:1.4 cwrapper:1.4.0.16 pkgsrc-2008Q1:1.4.0.14 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.12 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.10 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.8 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.6 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.4 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.2 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.3.0.6 pkgsrc-2006Q2-base:1.3 pkgsrc-2006Q1:1.3.0.4 pkgsrc-2006Q1-base:1.3 pkgsrc-2005Q4:1.3.0.2 pkgsrc-2005Q4-base:1.3; locks; strict; comment @# @; 1.5 date 2012.12.28.03.03.08; author dholland; state Exp; branches; next 1.4; 1.4 date 2006.07.22.04.23.29; author minskim; state Exp; branches; next 1.3; 1.3 date 2005.12.09.14.10.39; author joerg; state Exp; branches; next 1.2; 1.2 date 2005.11.08.21.39.12; author rillig; state Exp; branches; next 1.1; 1.1 date 2005.10.31.20.04.46; author tv; state Exp; branches; next ; desc @@ 1.5 log @Fix legacy C. Pass -Wall -W -Wmissing-declarations -Wwrite-strings on gcc45. - avoid implicit int, declare void functions void - return values from non-void functions - put most external declarations properly in header files - use some static and const - fix up a big mess with function pointer casting - use standard includes, don't provide own decls of standard functions - use types matching libc when providing own malloc, printf, and putchar - use functions correctly - silence assorted compiler warnings - fix some bugs exposed by compiler warnings - don't intentionally exercise signed overflow - remove some unused items - add patch comments to other patch (patch-aa) As this includes several fixes and removes some undefined behavior on a commonly reachable code path, bump PKGREVISION. @ text @$NetBSD: patch-ac,v 1.4 2006/07/22 04:23:29 minskim Exp $ - use standard headers (these functions are supposed to substitute for the libc ones, so they need to match stdlib.h exactly) - use own headers - declare void functions void - fix return and argument types --- mapmalloc.c.orig 2003-01-28 20:04:25.000000000 +0000 +++ mapmalloc.c @@@@ -54,18 +54,12 @@@@ #include #include #include -#ifdef __GLIBC__ -/* - * Broken GNU libc will include stdlib.h with conflicting - * malloc() types otherwise. - */ -#ifndef __NO_STRING_INLINES -#define __NO_STRING_INLINES -#endif /* !__NO_STRING_INLINES */ -#endif /* __GLIBC__ */ +#include #include #include "config.h" +#include "ex.h" +#include "ex_proto.h" #ifdef LANGMSG #include @@@@ -176,8 +170,6 @@@@ static MM *mm_global = NULL; static int zerofd = -1; #endif -extern int error __P((char *, ...)); - /* * Determine memory page size of OS */ @@@@ -308,7 +300,7 @@@@ mm_create(MM *mmPrev, size_t usize) * and/or next chunk when possible to form larger chunks out of * smaller ones. */ -static +static void mm_insert_chunk(MM *mm, mem_chunk *mcInsert) { mem_chunk *mc; @@@@ -429,7 +421,7 @@@@ mm_retrieve_chunk(MM *mm, size_t size) /* * Allocate a chunk of memory */ -char * +void * malloc(size_t usize) { MM *mm; @@@@ -469,10 +461,12 @@@@ nextpool: /* * Free a chunk of memory */ -free(char *ptr) +void +free(void *ptrV) { MM *mm; mem_chunk *mc; + char *ptr = ptrV; if (mm_global == NULL || ptr == NULL) return; @@@@ -494,12 +488,13 @@@@ free(char *ptr) /* * Reallocate a chunk of memory */ -char * -realloc(char *ptr, size_t usize) +void * +realloc(void *ptrV, size_t usize) { size_t size; mem_chunk *mc; char *vp; + char *ptr = ptrV; if (ptr == NULL) return malloc(usize); /* POSIX.1 semantics */ @@@@ -523,7 +518,7 @@@@ realloc(char *ptr, size_t usize) /* * Allocate and initialize a chunk of memory */ -char * +void * calloc(size_t number, size_t usize) { char *vp; @@@@ -534,38 +529,55 @@@@ calloc(size_t number, size_t usize) return vp; } +#ifndef __NetBSD__ /* signature does not agree with netbsd's libcompat */ /*ARGSUSED*/ -cfree(p, num, size) +void cfree(p, num, size) char *p; size_t num, size; { free(p); } +#endif + + +/* + * Not all systems have the following in libc, so avoid compiler warnings + * by inserting extra global declarations. + */ +char *memalign(size_t alignment, size_t size); +void *valloc(size_t size); +char *mallinfo(void); +int mallopt(void); +char *poolsbrk(intptr_t val); + /*ARGSUSED*/ char * memalign(alignment, size) size_t alignment, size; { + (void)alignment; + (void)size; return NULL; } /*ARGSUSED*/ -char * +void * valloc(size) size_t size; { + (void)size; return NULL; } char * -mallinfo() +mallinfo(void) { return NULL; } int -mallopt() +mallopt(void) { return -1; } @@@@ -574,5 +586,6 @@@@ mallopt() char * poolsbrk(intptr_t val) { + (void)val; return NULL; } @ 1.4 log @Adjust the valloc return value on Darwin not to conflict with the one declared in unistd.h. @ text @d1 1 a1 1 $NetBSD$ d3 8 a10 1 --- mapmalloc.c.orig 2003-01-28 12:04:25.000000000 -0800 d12 1 a12 1 @@@@ -54,6 +54,9 @@@@ d16 9 a24 1 +#if defined(__INTERIX) d26 87 d114 21 a134 4 #ifdef __GLIBC__ /* * Broken GNU libc will include stdlib.h with conflicting @@@@ -551,7 +554,11 @@@@ size_t alignment, size; d138 1 a138 1 +#if defined(__DragonFly__) || defined(__APPLE__) a139 3 +#else char * +#endif d143 24 @ 1.3 log @Adjust valloc return value on DragonFly to not conflict with unistd.h. @ text @d3 1 a3 1 --- mapmalloc.c.orig 2003-01-28 20:04:25.000000000 +0000 d19 1 a19 1 +#if defined(__DragonFly__) @ 1.2 log @Fixed patch-ac from tv to only change the code on Interix. This makes all other platforms work again. @ text @d1 1 a1 1 $NetBSD: patch-ac,v 1.1 2005/10/31 20:04:46 tv Exp $ d3 1 a3 1 --- mapmalloc.c.orig 2003-01-28 15:04:25.000000000 -0500 d15 12 @ 1.1 log @Include to get [u]intptr_t on Interix. @ text @d1 1 a1 1 $NetBSD$ d5 1 a5 1 @@@@ -54,6 +54,7 @@@@ d9 1 d11 1 @