move heap functions to own mod

This commit is contained in:
Vinzenz Schroeter 2025-05-07 08:53:49 +02:00
parent cf6e6385ec
commit 626a887480
17 changed files with 82 additions and 65 deletions

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{Bitmap, BitmapCommand, CompressionCode, Origin, Packet};

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{

View file

@ -1,4 +1,4 @@
use crate::{heap_drop, heap_move_nonnull};
use crate::mem::{heap_drop, heap_move_nonnull};
use servicepoint::{ClearCommand, FadeOutCommand, HardResetCommand};
use std::ptr::NonNull;

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{BitmapCommand, CharGrid, CharGridCommand, Origin, Packet};

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{
@ -65,11 +65,11 @@ impl SPCommand {
};
}
/// Tries to turn a [Packet] into a [TypedCommand].
/// Tries to turn a [Packet] into a [SPCommand].
///
/// The packet is deallocated in the process.
/// The packet is dropped in the process.
///
/// Returns: pointer to new [TypedCommand] instance or NULL if parsing failed.
/// Returns: pointer to new [SPCommand] instance or NULL if parsing failed.
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_generic_try_from_packet(
packet: NonNull<Packet>,
@ -142,9 +142,9 @@ pub unsafe extern "C" fn sp_cmd_generic_try_from_packet(
}))
}
/// Clones a [SPCommand] instance.
/// Clones an [SPCommand] instance.
///
/// returns: new [SPCommand] instance.
/// returns: a new [SPCommand] instance.
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_generic_clone(command: SPCommand) -> SPCommand {
unsafe {
@ -217,12 +217,12 @@ pub unsafe extern "C" fn sp_cmd_generic_clone(command: SPCommand) -> SPCommand {
}
}
/// Deallocates a [SPCommand].
/// Deallocates an [SPCommand].
///
/// # Examples
///
/// ```C
/// TypedCommand c = sp_command_clear();
/// SPCommand c = sp_cmd_clear_into_generic(sp_cmd_clear_new());
/// sp_command_free(c);
/// ```
#[no_mangle]
@ -248,10 +248,10 @@ pub unsafe extern "C" fn sp_cmd_generic_free(command: SPCommand) {
}
}
/// Turns a [TypedCommand] into a [Packet].
/// The [TypedCommand] gets consumed.
/// Tries to turn a [SPCommand] into a [Packet].
/// The [SPCommand] gets consumed.
///
/// Returns NULL in case of an error.
/// Returns tag [CommandTag::Invalid] in case of an error.
#[no_mangle]
pub unsafe extern "C" fn sp_cmd_generic_into_packet(
command: SPCommand,

View file

@ -1,4 +1,4 @@
use crate::{
use crate::mem::{
heap_clone, heap_drop, heap_move_nonnull, heap_move_ok, heap_remove,
};
use servicepoint::{