From 7b1a0d155d642e1f6f1288a7450e6b57b4087cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Mon, 29 Jun 2020 15:13:57 +0200 Subject: [PATCH 1/3] Fix typo Source: https://sources.debian.org/data/main/f/fcl/0.6.1-3/debian/patches/0001-Fix-typo.patch --- include/fcl/narrowphase/detail/gjk_solver_indep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fcl/narrowphase/detail/gjk_solver_indep.h b/include/fcl/narrowphase/detail/gjk_solver_indep.h index 14eb10ada..44ed5147b 100755 --- a/include/fcl/narrowphase/detail/gjk_solver_indep.h +++ b/include/fcl/narrowphase/detail/gjk_solver_indep.h @@ -191,7 +191,7 @@ struct FCL_EXPORT GJKSolver_indep << "\n epa max face num: " << solver.epa_max_face_num << "\n epa max vertex num: " << solver.epa_max_vertex_num << "\n epa max iterations: " << solver.epa_max_iterations - << "\n enable cahced guess: " << solver.enable_cached_guess; + << "\n enable cached guess: " << solver.enable_cached_guess; if (solver.enable_cached_guess) out << solver.cached_guess.transpose(); return out; } From 1d4787a0bf19b2edf5df221e0212355495cc743d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Mon, 29 Jun 2020 15:14:14 +0200 Subject: [PATCH 2/3] Call abort() on OOM instead of exit(1) Source: https://sources.debian.org/data/main/f/fcl/0.6.1-3/debian/patches/0002-Call-abort-on-OOM-instead-of-exit-1.patch --- include/fcl/broadphase/detail/interval_tree-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fcl/broadphase/detail/interval_tree-inl.h b/include/fcl/broadphase/detail/interval_tree-inl.h index 330b676e8..5c93cc43a 100644 --- a/include/fcl/broadphase/detail/interval_tree-inl.h +++ b/include/fcl/broadphase/detail/interval_tree-inl.h @@ -531,7 +531,7 @@ std::deque*> IntervalTree::query(S low, S high) recursion_node_stack_size *= 2; recursion_node_stack = (it_recursion_node *)realloc(recursion_node_stack, recursion_node_stack_size * sizeof(it_recursion_node)); if(recursion_node_stack == nullptr) - exit(1); + abort(); } recursion_node_stack[recursion_node_stack_top].start_node = x; recursion_node_stack[recursion_node_stack_top].try_right_branch = false; From c3ed3f6bb8d6728b0d8ca7f01ab66b611d639e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Wed, 18 Nov 2020 21:09:13 +0100 Subject: [PATCH 3/3] Replace memcpy with std::copy Source: https://sources.debian.org/data/main/f/fcl/0.6.1-3/debian/patches/0003-Replace-memcpy-with-std-copy.patch --- .../detail/hierarchy_tree_array-inl.h | 16 ++++++----- include/fcl/geometry/bvh/BVH_model-inl.h | 27 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/fcl/broadphase/detail/hierarchy_tree_array-inl.h b/include/fcl/broadphase/detail/hierarchy_tree_array-inl.h index 961b605ea..b4edc407e 100644 --- a/include/fcl/broadphase/detail/hierarchy_tree_array-inl.h +++ b/include/fcl/broadphase/detail/hierarchy_tree_array-inl.h @@ -42,6 +42,8 @@ #include "fcl/common/unused.h" +#include + namespace fcl { @@ -109,7 +111,7 @@ void HierarchyTree::init_0(NodeType* leaves, int n_leaves_) n_leaves = n_leaves_; root_node = NULL_NODE; nodes = new NodeType[n_leaves * 2]; - memcpy(nodes, leaves, sizeof(NodeType) * n_leaves); + std::copy(leaves, leaves + n_leaves, nodes); freelist = n_leaves; n_nodes = n_leaves; n_nodes_alloc = 2 * n_leaves; @@ -137,7 +139,7 @@ void HierarchyTree::init_1(NodeType* leaves, int n_leaves_) n_leaves = n_leaves_; root_node = NULL_NODE; nodes = new NodeType[n_leaves * 2]; - memcpy(nodes, leaves, sizeof(NodeType) * n_leaves); + std::copy(leaves, leaves + n_leaves, nodes); freelist = n_leaves; n_nodes = n_leaves; n_nodes_alloc = 2 * n_leaves; @@ -181,7 +183,7 @@ void HierarchyTree::init_2(NodeType* leaves, int n_leaves_) n_leaves = n_leaves_; root_node = NULL_NODE; nodes = new NodeType[n_leaves * 2]; - memcpy(nodes, leaves, sizeof(NodeType) * n_leaves); + std::copy(leaves, leaves + n_leaves, nodes); freelist = n_leaves; n_nodes = n_leaves; n_nodes_alloc = 2 * n_leaves; @@ -225,7 +227,7 @@ void HierarchyTree::init_3(NodeType* leaves, int n_leaves_) n_leaves = n_leaves_; root_node = NULL_NODE; nodes = new NodeType[n_leaves * 2]; - memcpy(nodes, leaves, sizeof(NodeType) * n_leaves); + std::copy(leaves, leaves + n_leaves, nodes); freelist = n_leaves; n_nodes = n_leaves; n_nodes_alloc = 2 * n_leaves; @@ -385,7 +387,7 @@ void HierarchyTree::balanceBottomup() NodeType* leaves_ = leaves; extractLeaves(root_node, leaves_); root_node = NULL_NODE; - memcpy(nodes, leaves, sizeof(NodeType) * n_leaves); + std::copy(leaves, leaves + n_leaves, nodes); freelist = n_leaves; n_nodes = n_leaves; for(size_t i = n_leaves; i < n_nodes_alloc; ++i) @@ -414,7 +416,7 @@ void HierarchyTree::balanceTopdown() NodeType* leaves_ = leaves; extractLeaves(root_node, leaves_); root_node = NULL_NODE; - memcpy(nodes, leaves, sizeof(NodeType) * n_leaves); + std::copy(leaves, leaves + n_leaves, nodes); freelist = n_leaves; n_nodes = n_leaves; for(size_t i = n_leaves; i < n_nodes_alloc; ++i) @@ -946,7 +948,7 @@ size_t HierarchyTree::allocateNode() NodeType* old_nodes = nodes; n_nodes_alloc *= 2; nodes = new NodeType[n_nodes_alloc]; - memcpy(nodes, old_nodes, n_nodes * sizeof(NodeType)); + std::copy(old_nodes, old_nodes + n_nodes, nodes); delete [] old_nodes; for(size_t i = n_nodes; i < n_nodes_alloc - 1; ++i) diff --git a/include/fcl/geometry/bvh/BVH_model-inl.h b/include/fcl/geometry/bvh/BVH_model-inl.h index 8dbd8b6a5..659cc10cd 100644 --- a/include/fcl/geometry/bvh/BVH_model-inl.h +++ b/include/fcl/geometry/bvh/BVH_model-inl.h @@ -40,6 +40,7 @@ #include "fcl/geometry/bvh/BVH_model.h" #include +#include namespace fcl { @@ -92,7 +93,7 @@ BVHModel::BVHModel(const BVHModel& other) if(other.vertices) { vertices = new Vector3[num_vertices]; - memcpy(vertices, other.vertices, sizeof(Vector3) * num_vertices); + std::copy(other.vertices, other.vertices + num_vertices, vertices); } else vertices = nullptr; @@ -100,7 +101,7 @@ BVHModel::BVHModel(const BVHModel& other) if(other.tri_indices) { tri_indices = new Triangle[num_tris]; - memcpy(tri_indices, other.tri_indices, sizeof(Triangle) * num_tris); + std::copy(other.tri_indices, other.tri_indices + num_tris, tri_indices); } else tri_indices = nullptr; @@ -108,7 +109,7 @@ BVHModel::BVHModel(const BVHModel& other) if(other.prev_vertices) { prev_vertices = new Vector3[num_vertices]; - memcpy(prev_vertices, other.prev_vertices, sizeof(Vector3) * num_vertices); + std::copy(other.prev_vertices, other.prev_vertices + num_vertices, prev_vertices); } else prev_vertices = nullptr; @@ -129,7 +130,7 @@ BVHModel::BVHModel(const BVHModel& other) } primitive_indices = new unsigned int[num_primitives]; - memcpy(primitive_indices, other.primitive_indices, sizeof(unsigned int) * num_primitives); + std::copy(other.primitive_indices, other.primitive_indices + num_primitives, primitive_indices); } else primitive_indices = nullptr; @@ -138,7 +139,7 @@ BVHModel::BVHModel(const BVHModel& other) if(other.bvs) { bvs = new BVNode[num_bvs]; - memcpy(bvs, other.bvs, sizeof(BVNode) * num_bvs); + std::copy(other.bvs, other.bvs + num_bvs, bvs); } else bvs = nullptr; @@ -270,7 +271,7 @@ int BVHModel::addVertex(const Vector3& p) return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(temp, vertices, sizeof(Vector3) * num_vertices); + std::copy(vertices, vertices + num_vertices, temp); delete [] vertices; vertices = temp; num_vertices_allocated *= 2; @@ -301,7 +302,7 @@ int BVHModel::addTriangle(const Vector3& p1, const Vector3& p2, const return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(temp, vertices, sizeof(Vector3) * num_vertices); + std::copy(vertices, vertices + num_vertices, temp); delete [] vertices; vertices = temp; num_vertices_allocated = num_vertices_allocated * 2 + 2; @@ -329,7 +330,7 @@ int BVHModel::addTriangle(const Vector3& p1, const Vector3& p2, const return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(temp, tri_indices, sizeof(Triangle) * num_tris); + std::copy(tri_indices, tri_indices + num_tris, temp); delete [] tri_indices; tri_indices = temp; num_tris_allocated *= 2; @@ -362,7 +363,7 @@ int BVHModel::addSubModel(const std::vector>& ps) return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(temp, vertices, sizeof(Vector3) * num_vertices); + std::copy(vertices, vertices + num_vertices, temp); delete [] vertices; vertices = temp; num_vertices_allocated = num_vertices_allocated * 2 + num_vertices_to_add - 1; @@ -398,7 +399,7 @@ int BVHModel::addSubModel(const std::vector>& ps, const std::vect return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(temp, vertices, sizeof(Vector3) * num_vertices); + std::copy(vertices, vertices + num_vertices, temp); delete [] vertices; vertices = temp; num_vertices_allocated = num_vertices_allocated * 2 + num_vertices_to_add - 1; @@ -428,7 +429,7 @@ int BVHModel::addSubModel(const std::vector>& ps, const std::vect return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(temp, tri_indices, sizeof(Triangle) * num_tris); + std::copy(tri_indices, tri_indices + num_tris, temp); delete [] tri_indices; tri_indices = temp; num_tris_allocated = num_tris_allocated * 2 + num_tris_to_add - 1; @@ -468,7 +469,7 @@ int BVHModel::endModel() std::cerr << "BVH Error! Out of memory for tri_indices array in endModel() call!" << std::endl; return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(new_tris, tri_indices, sizeof(Triangle) * num_tris); + std::copy(tri_indices, tri_indices + num_tris, new_tris); delete [] tri_indices; tri_indices = new_tris; num_tris_allocated = num_tris; @@ -482,7 +483,7 @@ int BVHModel::endModel() std::cerr << "BVH Error! Out of memory for vertices array in endModel() call!" << std::endl; return BVH_ERR_MODEL_OUT_OF_MEMORY; } - memcpy(new_vertices, vertices, sizeof(Vector3) * num_vertices); + std::copy(vertices, vertices + num_vertices, new_vertices); delete [] vertices; vertices = new_vertices; num_vertices_allocated = num_vertices;