#Can I depend on std.mem.Allocator.free checking for empty slices?

1 messages · Page 1 of 1 (latest)

edgy raven
#

For example, testing.allocator.free("") will do nothing. I wrote a struct which defaults some []const u8 fields to "" . This struct also has a deinit method which frees these fields. Is this a horrible idea?

vocal tangle
#

yes, the values returned from alloc and create depend on this behavior, since they return arbitrary pointer values for zero-length allocations

edgy raven
#

Thanks!