Skip to content

Commit d56489f

Browse files
committed
Temporary fix array destroy problem.
1 parent 6855914 commit d56489f

File tree

7 files changed

+17
-4
lines changed

7 files changed

+17
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
Cargo.lock
44
/.cargo
55
/vendor
6-
/core
6+
core

phper-alloc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use std::{
1313
ops::{Deref, DerefMut},
1414
};
1515

16+
// TODO Add ERc, for refcounted type.
17+
1618
/// The item which can be placed into container [EBox].
1719
pub trait EAllocatable {
1820
/// The method to free the heap allocated by `emalloc`, should call `efree` at the end.

phper-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The proc-macros for [phper](https://crates.io/crates/phper).
88
[Unlicense](https://github.com/jmjoy/phper/blob/master/LICENSE).
99
*/
1010

11-
// TODO Write a bridge macro for easy usage about register functions and classes.
11+
// TODO Write a bridge macro for easy usage about register functions and classes, like `cxx`.
1212

1313
mod alloc;
1414
mod inner;

phper-test/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ pub fn test_php_scripts_with_condition(
9595
stdout,
9696
stderr,
9797
);
98+
#[cfg(target_os = "linux")]
99+
if output.status.code().is_none() {
100+
use std::os::unix::process::ExitStatusExt;
101+
println!(
102+
"===== signal ======\nExitStatusExt is None, the signal is: {:?}",
103+
output.status.signal()
104+
);
105+
}
98106
if !condition(output) {
99107
panic!("test php file `{}` failed", path);
100108
}

phper/src/arrays.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ impl Array {
112112
impl EAllocatable for Array {
113113
fn free(ptr: *mut Self) {
114114
unsafe {
115-
zend_hash_destroy(ptr.cast());
115+
if (*ptr).inner.gc.refcount == 0 {
116+
zend_hash_destroy(ptr.cast());
117+
_efree(ptr.cast());
118+
}
116119
}
117120
}
118121
}

phper/src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use anyhow::anyhow;
99
use std::{convert::Infallible, error, ffi::FromBytesWithNulError, io, str::Utf8Error};
1010

1111
/// PHP Throwable, can cause throwing an exception when setting to [crate::values::Val].
12+
///
1213
/// TODO Write a derive macro for auto extends the item implements for enum.
1314
pub trait Throwable: error::Error {
1415
fn class_entry(&self) -> &StatelessClassEntry;

phper/src/strings.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::{
77
use std::{os::raw::c_char, slice::from_raw_parts, str, str::Utf8Error};
88

99
/// Wrapper of [crate::sys::zend_string].
10-
/// TODO Refactor to ZendString(EBox<zend_string>).
1110
#[repr(transparent)]
1211
pub struct ZendString {
1312
inner: zend_string,

0 commit comments

Comments
 (0)