Re:Efficient string copying and concatenation in C
by papermachete on Thursday September 12, 2019 @03:21PM
(#20955316)
>I
>I
>I
There is no 'I' in standard libraries :)
Re:Efficient string copying and concatenation in C
by saagarjha on Thursday September 12, 2019 @01:42PM
(#20954197)
How would you use the refcount?
Re:Efficient string copying and concatenation in C
by billziss on Thursday September 12, 2019 @01:53PM
(#20954311)
I use the refcount to avoid copying the string when passing it around. I just refcount it instead.
To clarify this is part of a larger library that includes other memory management machinery, such as autorelease pools, etc.
My personal variant uses 32-bits for length and 32-bits for refcount, which aligns well on most platforms, including 64-bit ones.
Something like:
Given a char pointer to get to the header you must do: