Re: What's the fastest way to check if a slice points to static data
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 24 11:05:55 PDT 2017
Petar Kirov [ZombineDev] wrote:
> ***
> But in any case, the null-terminated string was just an example
> application.
> I'm interested in a fast way to determine the "storage class" of the
> memory
> a slice or a pointer point to. I'm expecting some magic along the lines of
> checking the range of addresses that the rodata section resides in memory.
> Similar to how some allocators or the GC know if they own a range of
> memory.
> Any ideas on that?
> ***
the only query you can do is GC query (see `core.memory.CG` namespace,
`addrOf()` API, for example). it will tell you if something was allocated with D
GC or not.
yet it is not guaranteed to be fast (althru it is usually "fast enough").
i think this is all what you can get without resorting to ugly
platform-specific hacks (that will inevitably break ;-).
More information about the Digitalmars-d-learn
mailing list