• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / edge-runtime / 14351775254

09 Apr 2025 07:45AM UTC coverage: 51.393% (-0.08%) from 51.468%
14351775254

push

github

web-flow
build(deps): bump openssl from 0.10.70 to 0.10.72 (#530)

Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.70 to 0.10.72.
- [Release notes](https://github.com/sfackler/rust-openssl/releases)
- [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.70...openssl-v0.10.72)

---
updated-dependencies:
- dependency-name: openssl
  dependency-version: 0.10.72
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

17832 of 34697 relevant lines covered (51.39%)

5623.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.08
/ext/runtime/external_memory.rs
1
use std::ffi::c_void;
2
use std::sync::atomic::AtomicUsize;
3
use std::sync::atomic::Ordering;
4
use std::sync::Arc;
5
use std::sync::RwLock;
6

7
use deno_core::v8;
8
use deno_core::v8::UniqueRef;
9
use futures::task::AtomicWaker;
10

11
pub struct CustomAllocator {
12
  max: usize,
13
  count: AtomicUsize,
14
  waker: RwLock<Option<Arc<AtomicWaker>>>,
15
}
16

17
impl CustomAllocator {
18
  pub fn new(max: usize) -> Arc<Self> {
959✔
19
    Arc::new(Self {
959✔
20
      max,
959✔
21
      count: AtomicUsize::new(0),
959✔
22
      waker: RwLock::new(None),
959✔
23
    })
959✔
24
  }
959✔
25

26
  pub fn set_waker(&self, waker: Arc<AtomicWaker>) {
959✔
27
    _ = self.waker.try_write().unwrap().insert(waker);
959✔
28
  }
959✔
29

30
  pub fn into_v8_allocator(
959✔
31
    self: Arc<Self>,
959✔
32
  ) -> UniqueRef<deno_core::v8::Allocator> {
959✔
33
    let vtable: &'static v8::RustAllocatorVtable<CustomAllocator> =
959✔
34
      &v8::RustAllocatorVtable {
959✔
35
        allocate,
959✔
36
        allocate_uninitialized,
959✔
37
        free,
959✔
38
        reallocate,
959✔
39
        drop,
959✔
40
      };
959✔
41

959✔
42
    unsafe { v8::new_rust_allocator(Arc::into_raw(self), vtable) }
959✔
43
  }
959✔
44

45
  fn wake(&self) {
128,974✔
46
    if let Some(waker) = self.waker.try_read().ok().and_then(|it| it.clone()) {
128,974✔
47
      waker.wake();
128,974✔
48
    }
128,974✔
49
  }
128,974✔
50
}
51

52
#[allow(clippy::unnecessary_cast)]
53
unsafe extern "C" fn allocate(
28,909✔
54
  allocator: &CustomAllocator,
28,909✔
55
  n: usize,
28,909✔
56
) -> *mut c_void {
28,909✔
57
  allocator.count.fetch_add(n, Ordering::SeqCst);
28,909✔
58

28,909✔
59
  let count_loaded = allocator.count.load(Ordering::SeqCst);
28,909✔
60

28,909✔
61
  if count_loaded > allocator.max {
28,909✔
62
    return std::ptr::null::<*mut [u8]>() as *mut c_void;
8✔
63
  }
28,901✔
64

28,901✔
65
  allocator.wake();
28,901✔
66

28,901✔
67
  Box::into_raw(vec![0u8; n].into_boxed_slice()) as *mut [u8] as *mut c_void
28,901✔
68
}
28,909✔
69

70
#[allow(clippy::unnecessary_cast)]
71
#[allow(clippy::uninit_vec)]
72
unsafe extern "C" fn allocate_uninitialized(
35,623✔
73
  allocator: &CustomAllocator,
35,623✔
74
  n: usize,
35,623✔
75
) -> *mut c_void {
35,623✔
76
  allocator.count.fetch_add(n, Ordering::SeqCst);
35,623✔
77

35,623✔
78
  let count_loaded = allocator.count.load(Ordering::SeqCst);
35,623✔
79

35,623✔
80
  if count_loaded > allocator.max {
35,623✔
81
    return std::ptr::null::<*mut [u8]>() as *mut c_void;
×
82
  }
35,623✔
83

35,623✔
84
  let mut store = Vec::with_capacity(n);
35,623✔
85

35,623✔
86
  store.set_len(n);
35,623✔
87
  allocator.wake();
35,623✔
88

35,623✔
89
  Box::into_raw(store.into_boxed_slice()) as *mut [u8] as *mut c_void
35,623✔
90
}
35,623✔
91

92
unsafe extern "C" fn free(
64,450✔
93
  allocator: &CustomAllocator,
64,450✔
94
  data: *mut c_void,
64,450✔
95
  n: usize,
64,450✔
96
) {
64,450✔
97
  allocator.count.fetch_sub(n, Ordering::SeqCst);
64,450✔
98
  allocator.wake();
64,450✔
99

64,450✔
100
  let _ = Box::from_raw(std::slice::from_raw_parts_mut(data as *mut u8, n));
64,450✔
101
}
64,450✔
102

103
#[allow(clippy::unnecessary_cast)]
104
unsafe extern "C" fn reallocate(
×
105
  allocator: &CustomAllocator,
×
106
  prev: *mut c_void,
×
107
  oldlen: usize,
×
108
  newlen: usize,
×
109
) -> *mut c_void {
×
110
  allocator
×
111
    .count
×
112
    .fetch_add(newlen.wrapping_sub(oldlen), Ordering::SeqCst);
×
113

×
114
  let count_loaded = allocator.count.load(Ordering::SeqCst);
×
115

×
116
  if count_loaded > allocator.max {
×
117
    return std::ptr::null::<*mut [u8]>() as *mut c_void;
×
118
  }
×
119

×
120
  let old_store =
×
121
    Box::from_raw(std::slice::from_raw_parts_mut(prev as *mut u8, oldlen));
×
122
  let mut new_store = Vec::with_capacity(newlen);
×
123
  let copy_len = oldlen.min(newlen);
×
124

×
125
  new_store.extend_from_slice(&old_store[..copy_len]);
×
126
  new_store.resize(newlen, 0u8);
×
127
  allocator.wake();
×
128

×
129
  Box::into_raw(new_store.into_boxed_slice()) as *mut [u8] as *mut c_void
×
130
}
×
131

132
unsafe extern "C" fn drop(allocator: *const CustomAllocator) {
957✔
133
  Arc::from_raw(allocator);
957✔
134
}
957✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc