Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Does Bstrlib support garbage collection?

0
Posted

Does Bstrlib support garbage collection?

0

A. No. Certainly not directly. bstrings and CBStrings need to be correctly destroyed much like any allocated memory or object in C/C++ to avoid memory leaks. That said, both implementations allocate memory via malloc, realloc or new, so the garbage collection mechanisms that do exist for C/C++ (such as the Boehm garbage collector) should integrate with Bstrlib without issue. Schemes such as “reference counting” do not work in a language like C without a lot of hand holding (ADT construction, copying and destruction would have to precisely track references to any contained strings) and can inhibit the creation of thread safe solutions.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.