Skip to content

Commit c373634

Browse files
author
Kapu
committed
fix: Remove ARRAYS usage from openvx-buffer, use Box instead of Arc for VxCArray
1 parent b16d9ae commit c373634

868 files changed

Lines changed: 1089 additions & 156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

openvx-buffer/src/c_api.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#![allow(non_camel_case_types)]
44

55
use std::ffi::c_void;
6-
use std::sync::{RwLock, Mutex, Arc};
7-
use std::sync::atomic::AtomicUsize;
6+
use std::sync::{RwLock, atomic::AtomicUsize};
87
use std::collections::HashMap;
98
use openvx_core::c_api::{
109
vx_context, vx_graph, vx_array, vx_status, vx_enum, vx_size, vx_uint32, vx_map_id, vx_int32,
@@ -16,7 +15,7 @@ use openvx_core::c_api::{
1615
VX_ARRAY_CAPACITY, VX_ARRAY_ITEMTYPE, VX_ARRAY_NUMITEMS, VX_ARRAY_ITEMSIZE,
1716
VX_MEMORY_TYPE_HOST, VX_MEMORY_TYPE_NONE,
1817
};
19-
use openvx_core::unified_c_api::{vx_distribution, vxCreateDistribution, REFERENCE_COUNTS, REFERENCE_TYPES, USER_STRUCTS, ARRAYS};
18+
use openvx_core::unified_c_api::{vx_distribution, vxCreateDistribution, REFERENCE_COUNTS, REFERENCE_TYPES, USER_STRUCTS};
2019
use openvx_core::unified_c_api::{VX_TYPE_ARRAY};
2120
use openvx_core::c_api::vxGetContext;
2221

@@ -96,18 +95,6 @@ pub extern "C" fn vxCreateArray(
9695

9796
let array_ptr = Box::into_raw(array) as vx_array;
9897

99-
// Register in unified ARRAYS registry for vxQueryReference
100-
{
101-
if let Ok(mut arrays) = ARRAYS.lock() {
102-
// We need to create an Arc to the array for the registry
103-
// But we already used Box::into_raw, so we need to reconstruct
104-
let arc_array = unsafe { Arc::from_raw(array_ptr) };
105-
arrays.insert(array_ptr as usize, arc_array.clone());
106-
// Keep the Arc alive by not dropping it
107-
let _ = Arc::into_raw(arc_array);
108-
}
109-
}
110-
11198
// Register in reference counting
11299
unsafe {
113100
if let Ok(mut counts) = REFERENCE_COUNTS.lock() {
@@ -299,15 +286,6 @@ pub extern "C" fn vxCreateVirtualArray(
299286

300287
let array_ptr = Box::into_raw(array) as vx_array;
301288

302-
// Register in unified ARRAYS registry for vxQueryReference
303-
{
304-
if let Ok(mut arrays) = ARRAYS.lock() {
305-
let arc_array = unsafe { Arc::from_raw(array_ptr) };
306-
arrays.insert(array_ptr as usize, arc_array.clone());
307-
let _ = Arc::into_raw(arc_array);
308-
}
309-
}
310-
311289
// Register in reference counting
312290
unsafe {
313291
if let Ok(mut counts) = REFERENCE_COUNTS.lock() {
@@ -369,11 +347,6 @@ pub extern "C" fn vxReleaseArray(arr: *mut vx_array) -> vx_status {
369347
};
370348

371349
if should_free {
372-
// Remove from unified ARRAYS registry
373-
if let Ok(mut arrays) = ARRAYS.lock() {
374-
arrays.remove(&addr);
375-
}
376-
377350
// Remove from reference counts and types
378351
if let Ok(mut counts) = REFERENCE_COUNTS.lock() {
379352
counts.remove(&addr);
14 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file has an mtime of when this was started.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9c6f9d54e981b853
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"rustc":18276270781310494267,"features":"[]","declared_features":"[\"core\", \"rustc-dep-of-std\"]","target":13840298032947503755,"profile":2241668132362809309,"path":13664750095262734631,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cfg-if-b8c685c3ec20d4c2/dep-lib-cfg_if","checksum":false}}],"rustflags":[],"config":8247474407144887393,"compile_kind":0}
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file has an mtime of when this was started.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
653370ebda8c410c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"rustc":18276270781310494267,"features":"[]","declared_features":"[]","target":1524667692659508025,"profile":2241668132362809309,"path":16499075672617512382,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/equivalent-364f9b6ad821cc98/dep-lib-equivalent","checksum":false}}],"rustflags":[],"config":8247474407144887393,"compile_kind":0}
Binary file not shown.

0 commit comments

Comments
 (0)