From 80cfeb590e33e5a031d6eddd6f6a65ab83cf9082 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Thu, 24 Oct 2019 11:50:43 -0700 Subject: [PATCH] Clean up comments add headers too --- lib/runtime-c-api/src/import/mod.rs | 6 ++++-- lib/runtime-c-api/wasmer.h | 3 +++ lib/runtime-c-api/wasmer.hh | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/runtime-c-api/src/import/mod.rs b/lib/runtime-c-api/src/import/mod.rs index 87b6b7447af..3ef5a487cc4 100644 --- a/lib/runtime-c-api/src/import/mod.rs +++ b/lib/runtime-c-api/src/import/mod.rs @@ -100,7 +100,7 @@ pub unsafe extern "C" fn wasmer_import_object_get_import( }; if import.is_null() || import_export_value.is_null() { update_last_error(CApiError { - msg: "pointer to import and import_export_value must not be null".to_string(), + msg: "pointers to import and import_export_value must not be null".to_string(), }); return wasmer_result_t::WASMER_ERROR; } @@ -227,11 +227,13 @@ pub unsafe extern "C" fn wasmer_import_object_get_functions( #[no_mangle] /// Frees the memory acquired in `wasmer_import_object_get_functions` +/// +/// This function does not free the memory in `wasmer_import_object_t`; +/// it only frees memory allocated while querying a `wasmer_import_object_t`. pub unsafe extern "C" fn wasmer_import_object_imports_destroy( imports: *mut wasmer_import_t, imports_len: u32, ) { - // what's our null check policy here? let imports: &[wasmer_import_t] = &*slice::from_raw_parts_mut(imports, imports_len as usize); for import in imports { let _namespace: Vec = Vec::from_raw_parts( diff --git a/lib/runtime-c-api/wasmer.h b/lib/runtime-c-api/wasmer.h index 582a092c14e..57338a5bc51 100644 --- a/lib/runtime-c-api/wasmer.h +++ b/lib/runtime-c-api/wasmer.h @@ -494,6 +494,9 @@ wasmer_result_t wasmer_import_object_get_import(const wasmer_import_object_t *im /** * Frees the memory acquired in `wasmer_import_object_get_functions` + * + * This function does not free the memory in `wasmer_import_object_t`; + * it only frees memory allocated while querying a `wasmer_import_object_t`. */ void wasmer_import_object_imports_destroy(wasmer_import_t *imports, uint32_t imports_len); diff --git a/lib/runtime-c-api/wasmer.hh b/lib/runtime-c-api/wasmer.hh index 0dae80aa58e..521c6fa6cf2 100644 --- a/lib/runtime-c-api/wasmer.hh +++ b/lib/runtime-c-api/wasmer.hh @@ -391,6 +391,9 @@ wasmer_result_t wasmer_import_object_get_import(const wasmer_import_object_t *im uint32_t tag); /// Frees the memory acquired in `wasmer_import_object_get_functions` +/// +/// This function does not free the memory in `wasmer_import_object_t`; +/// it only frees memory allocated while querying a `wasmer_import_object_t`. void wasmer_import_object_imports_destroy(wasmer_import_t *imports, uint32_t imports_len); /// Creates a new empty import object.