albertogpz commented on code in PR #970:
URL: https://github.com/apache/geode-native/pull/970#discussion_r871476433


##########
cppcache/src/StreamDataInput.cpp:
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "StreamDataInput.hpp"
+
+#include <geode/DataInput.hpp>
+
+#include "Utils.hpp"
+#include "util/Log.hpp"
+
+namespace apache {
+namespace geode {
+namespace client {
+
+const size_t BUFF_SIZE = 3000;
+
+StreamDataInput::StreamDataInput(std::chrono::milliseconds timeout,
+                                 std::unique_ptr<Connector> connector,
+                                 const CacheImpl* cache, Pool* pool)
+    : DataInput(nullptr, 0, cache, pool) {
+  m_remainingTimeBeforeTimeout = timeout;
+  m_connector = std::move(connector);
+  m_buf = nullptr;
+  m_bufHead = m_buf;
+  m_bufLength = 0;
+}
+
+StreamDataInput::~StreamDataInput() {
+  if (m_bufHead != nullptr) {
+    free(const_cast<uint8_t*>(m_bufHead));

Review Comment:
   I do not think that's possible.
   The `DataInput` constructor has a `const uint8_t*` argument which is later 
assigned to the `m_bufHead` member variable.
   In the case of `StreamDataInput`, that pointer is not passed in the 
constructor to fill the member variable. Instead, it is allocated dynamically 
and it can even be reallocated.
   
   I could add a new `unique_ptr` member variable to `StreamDataInput` wrapping 
`m_bufHead` so that it manages the memory of `m_bufHead`. But then, I would not 
be able to use realloc in case I needed a larger size buffer. I would have to 
free m_bufHead and create a new one with a bigger size and copy into it the 
contents of the original one.
   I do not think it is worth it.



-- 
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: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to