Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH 3/3] autoconf: prepare for 2.70
- X-seq: zsh-workers 48439
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH 3/3] autoconf: prepare for 2.70
- Date: Fri, 9 Apr 2021 13:18:01 +0900
- Archived-at: <https://zsh.org/workers/48439>
- In-reply-to: <57530-1617921898.773095@9HdU.NV4Y.7xMR>
- List-id: <zsh-workers.zsh.org>
- References: <20201231054131.682544-1-felipe.contreras@gmail.com> <20201231054131.682544-4-felipe.contreras@gmail.com> <8940db24-8c70-45a6-8d3b-71047c1ce3b5@www.fastmail.com> <8638a7d8-418c-4065-be5d-21d42d693c56@www.fastmail.com> <57530-1617921898.773095@9HdU.NV4Y.7xMR>
> 2021/04/09 7:44, Oliver Kiddle <opk@xxxxxxx> wrote:
>
> Both this and the preceding part 1 patch look completely fine to me.
> I've read through this and checked against a couple of different systems
> and don't see an issue but I can't claim to be following what is new
> with autoconf 2.70. Unless anyone sees a reason to object, I'll apply
> these.
I also tested on a few systems and fund no problems.
I think mem.c can be further simplified as follows (discard unnecessary macros):
PS
Are there any systems that still require --enable-zsh-mem?
diff --git a/Src/mem.c b/Src/mem.c
index 5951e57ed..fb4be47bf 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1072,19 +1072,6 @@ zrealloc(void *ptr, size_t size)
# endif
#endif
-#if defined(_BSD) && !defined(STDC_HEADERS)
-# define FREE_RET_T int
-# define FREE_ARG_T char *
-# define FREE_DO_RET
-# define MALLOC_RET_T char *
-# define MALLOC_ARG_T size_t
-#else
-# define FREE_RET_T void
-# define FREE_ARG_T void *
-# define MALLOC_RET_T void *
-# define MALLOC_ARG_T size_t
-#endif
-
/* structure for building free list in blocks holding small blocks */
struct m_shdr {
@@ -1198,8 +1185,8 @@ static struct m_hdr *m_l;
#endif /* ZSH_MEM_DEBUG */
-MALLOC_RET_T
-malloc(MALLOC_ARG_T size)
+void *
+malloc(size_t size)
{
struct m_hdr *m, *mp, *mt;
long n, s, os = 0;
@@ -1226,7 +1213,7 @@ malloc(MALLOC_ARG_T size)
#if 1
size = 1;
#else
- return (MALLOC_RET_T) m_high;
+ return (void *) m_high;
#endif
queue_signals(); /* just queue signals rather than handling them */
@@ -1284,7 +1271,7 @@ malloc(MALLOC_ARG_T size)
#endif
unqueue_signals();
- return (MALLOC_RET_T) sh;
+ return (void *) sh;
}
/* we still want a small block but there were no block with a free
small block of the requested size; so we use the real allocation
@@ -1426,14 +1413,14 @@ malloc(MALLOC_ARG_T size)
#endif
unqueue_signals();
- return (MALLOC_RET_T) (((char *)m) + sizeof(struct m_hdr));
+ return (void *) (((char *)m) + sizeof(struct m_hdr));
}
#ifdef ZSH_MEM_DEBUG
m_m[m->len < (1024 * M_ISIZE) ? (m->len / M_ISIZE) : 1024]++;
#endif
unqueue_signals();
- return (MALLOC_RET_T) & m->next;
+ return (void *) & m->next;
}
/* this is an internal free(); the second argument may, but need not hold
@@ -1640,14 +1627,10 @@ zfree(void *p, int sz)
unqueue_signals();
}
-FREE_RET_T
-free(FREE_ARG_T p)
+void
+free(void *p)
{
zfree(p, 0); /* 0 means: size is unknown */
-
-#ifdef FREE_DO_RET
- return 0;
-#endif
}
/* this one is for strings (and only strings, real strings, real C strings,
@@ -1661,8 +1644,8 @@ zsfree(char *p)
zfree(p, strlen(p) + 1);
}
-MALLOC_RET_T
-realloc(MALLOC_RET_T p, MALLOC_ARG_T size)
+void *
+realloc(void *p, size_t size)
{
struct m_hdr *m = (struct m_hdr *)(((char *)p) - M_ISIZE), *mt;
char *r;
@@ -1673,12 +1656,12 @@ realloc(MALLOC_RET_T p, MALLOC_ARG_T size)
queue_signals();
r = malloc(size);
unqueue_signals();
- return (MALLOC_RET_T) r;
+ return (void *) r;
}
/* and some systems even do this... */
if (!p || !size)
- return (MALLOC_RET_T) p;
+ return p;
queue_signals(); /* just queue signals caught rather than handling them */
@@ -1707,17 +1690,17 @@ realloc(MALLOC_RET_T p, MALLOC_ARG_T size)
free(p);
unqueue_signals();
- return (MALLOC_RET_T) r;
+ return (void *) r;
}
-MALLOC_RET_T
-calloc(MALLOC_ARG_T n, MALLOC_ARG_T size)
+void *
+calloc(size_t n, size_t size)
{
long l;
char *r;
if (!(l = n * size))
- return (MALLOC_RET_T) m_high;
+ return (void *) m_high;
/*
* use realloc() (with a NULL `p` argument it behaves exactly the same
@@ -1729,7 +1712,7 @@ calloc(MALLOC_ARG_T n, MALLOC_ARG_T size)
memset(r, 0, l);
- return (MALLOC_RET_T) r;
+ return (void *) r;
}
#ifdef ZSH_MEM_DEBUG
Messages sorted by:
Reverse Date,
Date,
Thread,
Author