Skip to content

Commit af62e4c

Browse files
committed
Remove accesskit_custom_action_new_with_length, add comments specifying ownership
1 parent f9092be commit af62e4c

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

include/accesskit.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,7 @@ typedef struct accesskit_opt_text_selection {
869869
} accesskit_opt_text_selection;
870870

871871
/**
872-
* Use `accesskit_custom_action_new` or
873-
* `accesskit_custom_action_new_with_length` to create this struct. Do not
872+
* Use `accesskit_custom_action_new` or to create this struct. Do not
874873
* reallocate `description`.
875874
*
876875
* When you get this struct, you are responsible for freeing `description`.
@@ -2092,12 +2091,6 @@ void accesskit_node_clear_text_selection(struct accesskit_node *node);
20922091
struct accesskit_custom_action accesskit_custom_action_new(
20932092
int32_t id, const char *description);
20942093

2095-
/**
2096-
* The string must not contain null bytes.
2097-
*/
2098-
struct accesskit_custom_action accesskit_custom_action_new_with_length(
2099-
int32_t id, size_t length, const char *description);
2100-
21012094
void accesskit_custom_actions_free(struct accesskit_custom_actions *value);
21022095

21032096
/**
@@ -2131,9 +2124,15 @@ void accesskit_tree_free(struct accesskit_tree *tree);
21312124
*/
21322125
char *accesskit_tree_get_toolkit_name(const struct accesskit_tree *tree);
21332126

2127+
/**
2128+
* Caller is responsible for freeing the memory pointed by `toolkit_name`
2129+
*/
21342130
void accesskit_tree_set_toolkit_name(struct accesskit_tree *tree,
21352131
const char *toolkit_name);
21362132

2133+
/**
2134+
* Caller is responsible for freeing the memory pointed by `toolkit_name`
2135+
*/
21372136
void accesskit_tree_set_toolkit_name_with_length(struct accesskit_tree *tree,
21382137
size_t length,
21392138
const char *toolkit_name);
@@ -2145,9 +2144,15 @@ void accesskit_tree_clear_toolkit_name(struct accesskit_tree *tree);
21452144
*/
21462145
char *accesskit_tree_get_toolkit_version(const struct accesskit_tree *tree);
21472146

2147+
/**
2148+
* Caller is responsible for freeing the memory pointed by `toolkit_version`
2149+
*/
21482150
void accesskit_tree_set_toolkit_version(struct accesskit_tree *tree,
21492151
const char *toolkit_version);
21502152

2153+
/**
2154+
* Caller is responsible for freeing the memory pointed by `toolkit_version`
2155+
*/
21512156
void accesskit_tree_set_toolkit_version_with_length(
21522157
struct accesskit_tree *tree, size_t length, const char *toolkit_version);
21532158

src/common.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,7 @@ impl node {
665665
}
666666
clearer! { accesskit_node_clear_text_selection, clear_text_selection }
667667

668-
/// Use `accesskit_custom_action_new` or
669-
/// `accesskit_custom_action_new_with_length` to create this struct. Do not
668+
/// Use `accesskit_custom_action_new` or to create this struct. Do not
670669
/// reallocate `description`.
671670
///
672671
/// When you get this struct, you are responsible for freeing `description`.
@@ -692,23 +691,6 @@ impl custom_action {
692691
description: description.into_raw(),
693692
}
694693
}
695-
696-
/// The string must not contain null bytes.
697-
#[no_mangle]
698-
pub extern "C" fn accesskit_custom_action_new_with_length(
699-
id: i32,
700-
length: usize,
701-
description: *const c_char,
702-
) -> custom_action {
703-
let description = CString::new(String::from_utf8_lossy(
704-
unsafe { slice::from_raw_parts(description as *const u8, length) }
705-
).into_owned())
706-
.unwrap();
707-
Self {
708-
id,
709-
description: description.into_raw(),
710-
}
711-
}
712694
}
713695

714696
impl Drop for custom_action {
@@ -795,6 +777,7 @@ impl tree {
795777
}
796778
}
797779

780+
/// Caller is responsible for freeing the memory pointed by `toolkit_name`
798781
#[no_mangle]
799782
pub extern "C" fn accesskit_tree_set_toolkit_name(
800783
tree: *mut tree,
@@ -806,6 +789,7 @@ impl tree {
806789
));
807790
}
808791

792+
/// Caller is responsible for freeing the memory pointed by `toolkit_name`
809793
#[no_mangle]
810794
pub extern "C" fn accesskit_tree_set_toolkit_name_with_length(
811795
tree: *mut tree,
@@ -834,6 +818,7 @@ impl tree {
834818
}
835819
}
836820

821+
/// Caller is responsible for freeing the memory pointed by `toolkit_version`
837822
#[no_mangle]
838823
pub extern "C" fn accesskit_tree_set_toolkit_version(
839824
tree: *mut tree,
@@ -845,6 +830,7 @@ impl tree {
845830
));
846831
}
847832

833+
/// Caller is responsible for freeing the memory pointed by `toolkit_version`
848834
#[no_mangle]
849835
pub extern "C" fn accesskit_tree_set_toolkit_version_with_length(
850836
tree: *mut tree,

0 commit comments

Comments
 (0)