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

davidcole1340 / ext-php-rs / 14501981872

16 Apr 2025 08:30PM UTC coverage: 14.129% (+0.7%) from 13.479%
14501981872

push

github

web-flow
style(clippy): apply pedantic rules

Refs: #418

41 of 345 new or added lines in 46 files covered. (11.88%)

48 existing lines in 25 files now uncovered.

553 of 3914 relevant lines covered (14.13%)

1.3 hits per line

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

0.0
/src/alloc.rs
1
//! Functions relating to the Zend Memory Manager, used to allocate
2
//! request-bound memory.
3

4
use cfg_if::cfg_if;
5

6
use crate::ffi::{_efree, _emalloc};
7
use std::{alloc::Layout, ffi::c_void};
8

9
/// Uses the PHP memory allocator to allocate request-bound memory.
10
///
11
/// # Parameters
12
///
13
/// * `layout` - The layout of the requested memory.
14
///
15
/// # Returns
16
///
17
/// A pointer to the memory allocated.
18
#[must_use]
UNCOV
19
pub fn emalloc(layout: Layout) -> *mut u8 {
×
20
    // TODO account for alignment
21
    let size = layout.size();
×
22

23
    (unsafe {
×
NEW
24
        cfg_if! {
×
NEW
25
            if #[cfg(php_debug)] {
×
NEW
26
                #[allow(clippy::used_underscore_items)]
×
NEW
27
                _emalloc(size as _, std::ptr::null_mut(), 0, std::ptr::null_mut(), 0)
×
28
            } else {
NEW
29
                #[allow(clippy::used_underscore_items)]
×
NEW
30
                _emalloc(size as _)
×
31
            }
32
        }
33
    })
34
    .cast::<u8>()
35
}
36

37
/// Frees a given memory pointer which was allocated through the PHP memory
38
/// manager.
39
///
40
/// # Parameters
41
///
42
/// * `ptr` - The pointer to the memory to free.
43
///
44
/// # Safety
45
///
46
/// Caller must guarantee that the given pointer is valid (aligned and non-null)
47
/// and was originally allocated through the Zend memory manager.
48
pub unsafe fn efree(ptr: *mut u8) {
×
NEW
49
    cfg_if! {
×
NEW
50
        if #[cfg(php_debug)] {
×
NEW
51
            #[allow(clippy::used_underscore_items)]
×
NEW
52
            _efree(
×
NEW
53
                ptr.cast::<c_void>(),
×
NEW
54
                std::ptr::null_mut(),
×
NEW
55
                0,
×
NEW
56
                std::ptr::null_mut(),
×
NEW
57
                0,
×
58
            )
59
        } else {
NEW
60
            #[allow(clippy::used_underscore_items)]
×
NEW
61
            _efree(ptr.cast::<c_void>());
×
62
        }
63
    }
64
}
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