mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <Jens.Gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: [musl] [C23 new stdlib 1/3] C23: add the new interfaces free_sized and free_aligned_sized for stdlib.h
Date: Wed, 31 May 2023 12:05:15 +0200	[thread overview]
Message-ID: <a0eed5b4ed038ca974a6530762180af13493740b.1685527375.git.Jens.Gustedt@inria.fr> (raw)
In-Reply-To: <cover.1685527375.git.Jens.Gustedt@inria.fr>

For the moment, these are just trivial wrappers that ignored their
parameters other than the pointer.

The names were not previously reserved, so they could generate naming
conflicts with application code.

The "implementation" is just a trivial wrapper around free. This could
eventually replaced by implementations that are more efficient than
that.
---
 dynamic.list                    | 2 ++
 include/stdlib.h                | 2 ++
 src/malloc/free_aligned_sized.c | 6 ++++++
 src/malloc/free_sized.c         | 7 +++++++
 4 files changed, 17 insertions(+)
 create mode 100644 src/malloc/free_aligned_sized.c
 create mode 100644 src/malloc/free_sized.c

diff --git a/dynamic.list b/dynamic.list
index ee0d363b..f13db826 100644
--- a/dynamic.list
+++ b/dynamic.list
@@ -10,6 +10,8 @@ malloc;
 calloc;
 realloc;
 free;
+free_sized;
+free_aligned_sized;
 memalign;
 posix_memalign;
 aligned_alloc;
diff --git a/include/stdlib.h b/include/stdlib.h
index 037e4dc4..2f46e6aa 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -41,6 +41,8 @@ void *malloc (size_t);
 void *calloc (size_t, size_t);
 void *realloc (void *, size_t);
 void free (void *);
+void free_sized (void *, size_t);
+void free_aligned_sized (void *, size_t, size_t);
 void *aligned_alloc(size_t, size_t);
 
 __noreturn void abort (void);
diff --git a/src/malloc/free_aligned_sized.c b/src/malloc/free_aligned_sized.c
new file mode 100644
index 00000000..bdfd0cee
--- /dev/null
+++ b/src/malloc/free_aligned_sized.c
@@ -0,0 +1,6 @@
+#include <stdlib.h>
+
+void free_aligned_sized (void *p, size_t alignment, size_t size)
+{
+	free(p);
+}
diff --git a/src/malloc/free_sized.c b/src/malloc/free_sized.c
new file mode 100644
index 00000000..fbacc516
--- /dev/null
+++ b/src/malloc/free_sized.c
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+
+void free_sized (void *p, size_t size)
+{
+	free(p);
+}
+
-- 
2.34.1


  reply	other threads:[~2023-05-31 10:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 10:05 [musl] [C23 new stdlib 0/3] Jens Gustedt
2023-05-31 10:05 ` Jens Gustedt [this message]
2023-05-31 10:05 ` [musl] [C23 new stdlib 2/3] C23: add the memalignment function Jens Gustedt
2023-05-31 10:05 ` [musl] [C23 new stdlib 3/3] C23: implement the new strfrom[dfl] functions Jens Gustedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0eed5b4ed038ca974a6530762180af13493740b.1685527375.git.Jens.Gustedt@inria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).