@pmatilai commented on this pull request.


>  }
 
 StringBuf freeStringBuf(StringBuf sb)
 {
-    if (sb) {
-       sb->buf = _free(sb->buf);
-       sb = _free(sb);
-    }
-    return sb;
+    delete sb;

Oh, absolutely. This is really just stage 1 of the C++ onboarding, with many 
more to follow as time permits. The early steps look something like this:

Stage 1: natively allocate everything to allow use of non-trivial structures 
within
Stage 2: make our structs behave in STL containers (ie add destructors and 
copy-control)
Stage 3: take advantage of smart pointers and similar (look to replace manual 
reference counting, mutex locking and such)
...

And of course, look for opportunities to move stuff over to STL types is an 
on-going thing. I've been eliminating explicit new/delete where easily achieved 
when moving to STL containers. Stage 1 is sticking with these manual 
allocations just to keep things simple, just moving to STL containers presents 
plenty enough of unexpected side-effects :smile: 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3099#discussion_r1602639404
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/3099/review/2059629...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to