summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-memfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd-bus/sd-memfd.c')
-rw-r--r--src/libsystemd-bus/sd-memfd.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsystemd-bus/sd-memfd.c b/src/libsystemd-bus/sd-memfd.c
index 2712a26f66..bd14da3a70 100644
--- a/src/libsystemd-bus/sd-memfd.c
+++ b/src/libsystemd-bus/sd-memfd.c
@@ -205,3 +205,27 @@ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) {
return r;
}
+
+int sd_memfd_new_and_map(sd_memfd **m, size_t sz, void **p) {
+ sd_memfd *n;
+ int r;
+
+ r = sd_memfd_new(&n);
+ if (r < 0)
+ return r;
+
+ r = sd_memfd_set_size(n, sz);
+ if (r < 0) {
+ sd_memfd_free(n);
+ return r;
+ }
+
+ r = sd_memfd_map(n, 0, sz, p);
+ if (r < 0) {
+ sd_memfd_free(n);
+ return r;
+ }
+
+ *m = n;
+ return 0;
+}