@@ -198,17 +198,17 @@ pub fn createMapping(size: usize) SharedMemoryError!Handle {
198198 };
199199 defer std .heap .page_allocator .free (random_name );
200200
201- const shm_name = std .fmt .allocPrintZ (
201+ const shm_name = std .fmt .allocPrint (
202202 std .heap .page_allocator ,
203- "{s}" ,
203+ "{s}\x00 " ,
204204 .{random_name },
205205 ) catch {
206206 return error .OutOfMemory ;
207207 };
208208 defer std .heap .page_allocator .free (shm_name );
209-
209+ const shm_name_null_terminated = shm_name [ 0 .. shm_name . len - 1 : 0 ];
210210 const fd = posix .shm_open (
211- shm_name . ptr ,
211+ shm_name_null_terminated ,
212212 @as (u32 , @bitCast (std.posix.O { .ACCMODE = .RDWR , .CREAT = true , .EXCL = true })),
213213 0o600 ,
214214 );
@@ -218,7 +218,7 @@ pub fn createMapping(size: usize) SharedMemoryError!Handle {
218218 }
219219
220220 // Immediately unlink so it gets cleaned up when all references are closed
221- _ = posix .shm_unlink (shm_name . ptr );
221+ _ = posix .shm_unlink (shm_name_null_terminated );
222222
223223 // Set the size of the shared memory
224224 std .posix .ftruncate (fd , size ) catch {
@@ -254,13 +254,13 @@ pub fn openMapping(allocator: std.mem.Allocator, name: []const u8) SharedMemoryE
254254 return handle .? ;
255255 },
256256 .macos , .freebsd , .openbsd , .netbsd = > {
257- const shm_name = std .fmt .allocPrintZ (allocator , "/{s}" , .{name }) catch {
257+ const shm_name = std .fmt .allocPrint (allocator , "/{s}\x00 " , .{name }) catch {
258258 return error .OutOfMemory ;
259259 };
260260 defer allocator .free (shm_name );
261-
261+ const shm_name_null_terminated = shm_name [ 0 .. shm_name . len - 1 : 0 ];
262262 const fd = posix .shm_open (
263- shm_name . ptr ,
263+ shm_name_null_terminated ,
264264 @as (u32 , @bitCast (std.posix.O { .ACCMODE = .RDWR })),
265265 0 ,
266266 );
0 commit comments