Merge 'sqlite3: Implement sqlite3_malloc() and sqlite3_free()' from Pekka Enberg

Closes #2783
This commit is contained in:
Pekka Enberg
2025-08-25 18:15:52 +03:00
committed by GitHub

View File

@@ -508,13 +508,24 @@ pub unsafe extern "C" fn sqlite3_limit(
}
#[no_mangle]
pub unsafe extern "C" fn sqlite3_malloc64(_n: ffi::c_int) -> *mut ffi::c_void {
stub!();
pub unsafe extern "C" fn sqlite3_malloc(n: ffi::c_int) -> *mut ffi::c_void {
sqlite3_malloc64(n)
}
#[no_mangle]
pub unsafe extern "C" fn sqlite3_free(_ptr: *mut ffi::c_void) {
stub!();
pub unsafe extern "C" fn sqlite3_malloc64(n: ffi::c_int) -> *mut ffi::c_void {
if n <= 0 {
return std::ptr::null_mut();
}
libc::malloc(n as usize)
}
#[no_mangle]
pub unsafe extern "C" fn sqlite3_free(ptr: *mut ffi::c_void) {
if ptr.is_null() {
return;
}
libc::free(ptr);
}
/// Returns the error code for the most recent failed API call to connection.