yiguolei commented on code in PR #58004:
URL: https://github.com/apache/doris/pull/58004#discussion_r2532471622
##########
be/src/geo/wkt_parse_type.h:
##########
@@ -33,15 +35,22 @@ struct GeoCoordinateList {
};
struct GeoCoordinateListList {
- ~GeoCoordinateListList() {
- for (auto item : list) {
- delete item;
- }
- }
GeoCoordinateListList() = default;
- GeoCoordinateListList(GeoCoordinateListList&& other) :
list(std::move(other.list)) {}
- void add(GeoCoordinateList* coordinates) { list.push_back(coordinates); }
- std::vector<GeoCoordinateList*> list;
+ GeoCoordinateListList(GeoCoordinateListList&& other) = default;
+ GeoCoordinateListList& operator=(GeoCoordinateListList&& other) = default;
+ GeoCoordinateListList(const GeoCoordinateListList&) = delete;
+ GeoCoordinateListList& operator=(const GeoCoordinateListList&) = delete;
+
+ void add(std::unique_ptr<GeoCoordinateList> coordinates) {
+ list.emplace_back(std::move(coordinates));
+ }
+
+ void add(GeoCoordinateList*& coordinates) {
+ list.emplace_back(std::unique_ptr<GeoCoordinateList>(coordinates));
Review Comment:
这种接口写的风险都很大。 外部传递指针,你这49行,直接改unique ptr,万一外部是用uniqueptr.get
的方式来弄的指针,这里就会导致被析构两次。
不能在一个函数里面改变了对象的归属。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]