[fpc-devel] function RefCount(String) ?

Martin lazarus at mfriebe.de
Mon Nov 16 02:01:49 CET 2009


Is there a fundtion to get the current RefCount of a String?

I know there is UniqueString, which will ensure the ref-count is 1. But 
that's not what i am looking for.

When scanning some large string for substrings, each time I find a 
substring it will be a uniquestring (even if it has the same content as 
a previous found substring).
So I want to add it to some sort of cache, and then if I find the same 
string again, use the one from the cache (which will increase the 
refcount, and I can free the newly found one) => This would avoid of 
having potentially thousands of copies of the same string....

I can't use pchar, or any pointer into the original string, since the 
original string (the one that is searched) will be discarded too.

Now, of course strings in the cache should only live for as long as they 
are used somewhere else too (their ref-count is greater than 1). Of 
course I can implement my own refcount => but since there already is one.

so is their an official way to get hold of the refcount?

Martin



More information about the fpc-devel mailing list