Skip to content

Commit 49a3a63

Browse files
committed
Fix with chatbot suggestion
1 parent ad01277 commit 49a3a63

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if [ $? -ne 0 ]; then
3636
fi
3737

3838
python scripts/sync_version.py
39-
python -m pip3 install -e . -vvv
39+
python -m pip install -e . -vvv
4040

4141
# Test that the import works
4242
echo "Testing import..."

src/export_cache.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ namespace libcachesim {
2828

2929
namespace py = pybind11;
3030

31+
const cache_obj_t* LHD_HIT_MARKER = reinterpret_cast<cache_obj_t *>(0x1);
32+
3133
// Custom deleters for smart pointers
3234
struct CacheDeleter {
3335
void operator()(cache_t* ptr) const {
@@ -286,11 +288,11 @@ void export_cache(py::module& m) {
286288
return py::none();
287289
}
288290
// NOTE(haocheng): For LHD only, return a dummy object for hit
289-
if (obj == reinterpret_cast<cache_obj_t *>(0x1)) {
290-
cache_obj_t* obj = new cache_obj_t();
291-
obj->obj_id = req.obj_id;
292-
obj->obj_size = req.obj_size;
293-
return py::cast(std::unique_ptr<cache_obj_t, CacheObjectDeleter>(obj));
291+
if (obj == LHD_HIT_MARKER) {
292+
cache_obj_t* dummy_obj = static_cast<cache_obj_t*>(calloc(1, sizeof(cache_obj_t)));
293+
dummy_obj->obj_id = req.obj_id;
294+
dummy_obj->obj_size = req.obj_size;
295+
return py::cast(std::unique_ptr<cache_obj_t, CacheObjectDeleter>(dummy_obj));
294296
}
295297
return py::cast(obj, py::return_value_policy::reference);
296298
},

0 commit comments

Comments
 (0)