So a lovely C library does its own opaque allocation, and provides access to the malloc'd memory, and that memory's length. Instead of copying the results into garbage collected memory (which would probably be smart) I was thinking about creating a structure like:

struct WrappedString {
  byte* ptr;
  size_t length;
}

And then implementing opIndex for it, and opEquals for all the different string types, and conversions to those types, and then it occurred to me that this sounds like a lot of work. Has anybody done this already? Made a pointer/length pair, that acts like a string?

Reply via email to