Adding Java and C++ to the MQTT benchmarks or: How I Learned to Stop Worrying and Love the Garbage Collector

Walter Bright newshound2 at digitalmars.com
Thu Jan 9 09:15:46 PST 2014


On 1/9/2014 2:46 AM, "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Thursday, 9 January 2014 at 09:58:24 UTC, Walter Bright wrote:
>> Please explain how this can work passing both string literals and allocated
>> strings to cat().
>
> By having your own string allocator that tests for membership when you free (if
> you allow free and foreign strings in your cat)?

How does that work when you pass it "hello"? allocated with malloc()? basically 
any data that has mixed ancestry?

Note that your code doesn't always have control over this - you may have written 
a library intended to be used by others, or you may be calling a library written 
by others.


>> How do you return a string that is the path part of a path/filename? (The
>> terminating 0 is not a problem solved by creating your own allocator.)
> If you discard the original you split at '/'.

That doesn't work if you pass a string literal, or if you are not the owner of 
the data.


> If you use your own
> stringallocator you don't have to worry about free... You either let the garbage
> remain until the pool is released or have a separate allocation structure that
> allows internal splits (no private size info before first char).

That doesn't work if you're passing strings with mixed ancestry.



More information about the Digitalmars-d mailing list