diff --git a/libretroshare/src/turtle/rsturtleitem.cc b/libretroshare/src/turtle/rsturtleitem.cc index 6e3feee52..a77559b15 100644 --- a/libretroshare/src/turtle/rsturtleitem.cc +++ b/libretroshare/src/turtle/rsturtleitem.cc @@ -100,15 +100,20 @@ void RsTurtleGenericSearchRequestItem::serial_process(RsGenericSerializer::Seria } RsTurtleSearchRequestItem *RsTurtleGenericSearchRequestItem::clone() const { - RsTurtleGenericSearchRequestItem *sr = new RsTurtleGenericSearchRequestItem ; - - memcpy(sr,this,sizeof(RsTurtleGenericSearchRequestItem)) ; - - sr->search_data = (unsigned char*)rs_malloc(search_data_len) ; - memcpy(sr->search_data,search_data,search_data_len) ; - - return sr ; + return new RsTurtleGenericSearchRequestItem(*this) ; } + +RsTurtleGenericSearchRequestItem::RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem& it) + : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST) +{ + search_data_len = it.search_data_len ; + search_data = (unsigned char*)rs_malloc(it.search_data_len) ; + service_id = it.service_id ; + request_type = it.request_type ; + + memcpy(search_data,it.search_data,it.search_data_len) ; +} + template<> uint32_t RsTypeSerializer::serial_size(const RsRegularExpression::LinearizedExpression& r) { uint32_t s = 0 ; diff --git a/libretroshare/src/turtle/rsturtleitem.h b/libretroshare/src/turtle/rsturtleitem.h index 1f4893087..5f29ca0ea 100644 --- a/libretroshare/src/turtle/rsturtleitem.h +++ b/libretroshare/src/turtle/rsturtleitem.h @@ -185,7 +185,7 @@ class RsTurtleGenericSearchRequestItem: public RsTurtleSearchRequestItem void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); private: - RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem&): RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_GENERIC_SEARCH_REQUEST) {} // make the object non copi-able. + RsTurtleGenericSearchRequestItem(const RsTurtleGenericSearchRequestItem&); // make the object non copi-able. RsTurtleGenericSearchRequestItem& operator=(const RsTurtleGenericSearchRequestItem&) { return *this;} }; class RsTurtleSearchResultItem: public RsTurtleItem