Skip to content

Commit

Permalink
Merge #1335
Browse files Browse the repository at this point in the history
1335:  fix(runtime-c-api) Change mutability of `memory` for `const` in `wasmer_memory_data_length` r=Hywan a=Hywan

This PR changes mutability of `memory` for `const` in `wasmer_memory_data_length` to be more consistent regarding the returned value of `wasmer_instance_context_memory`.

Fixes #1314. 
Fixes wasmerio/docs.wasmer.io#43.

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
Co-authored-by: Ivan Enderlin <ivan.enderlin@wanadoo.fr>
  • Loading branch information
3 people authored Mar 27, 2020
2 parents 531ec45 + 2276d16 commit 204f06e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## **[Unreleased]**

- [#1335](https://github.com/wasmerio/wasmer/pull/1335) Change mutability of `memory` to `const` in `wasmer_memory_data_length` in the C API
- [#1329](https://github.com/wasmerio/wasmer/pull/1329) New numbers and strings instructions for WIT
- [#1332](https://github.com/wasmerio/wasmer/pull/1332) Add option to `CompilerConfig` to force compiler IR verification off even when `debug_assertions` are enabled. This can be used to make debug builds faster, which may be important if you're creating a library that wraps Wasmer and depend on the speed of debug builds.
- [#1320](https://github.com/wasmerio/wasmer/pull/1320) Change `custom_sections` field in `ModuleInfo` to be more standards compliant by allowing multiple custom sections with the same name. To get the old behavior with the new API, you can add `.last().unwrap()` to accesses. For example, `module_info.custom_sections["custom_section_name"].last().unwrap()`.
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-c-api/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub extern "C" fn wasmer_memory_data(memory: *const wasmer_memory_t) -> *mut u8
/// ```
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
pub extern "C" fn wasmer_memory_data_length(memory: *mut wasmer_memory_t) -> u32 {
pub extern "C" fn wasmer_memory_data_length(memory: *const wasmer_memory_t) -> u32 {
if memory.is_null() {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-c-api/wasmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ uint8_t *wasmer_memory_data(const wasmer_memory_t *memory);
* uint32_t memory_data_length = wasmer_memory_data_length(memory);
* ```
*/
uint32_t wasmer_memory_data_length(wasmer_memory_t *memory);
uint32_t wasmer_memory_data_length(const wasmer_memory_t *memory);

/**
* Frees memory for the given `wasmer_memory_t`.
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-c-api/wasmer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ uint8_t *wasmer_memory_data(const wasmer_memory_t *memory);
/// ```c
/// uint32_t memory_data_length = wasmer_memory_data_length(memory);
/// ```
uint32_t wasmer_memory_data_length(wasmer_memory_t *memory);
uint32_t wasmer_memory_data_length(const wasmer_memory_t *memory);

/// Frees memory for the given `wasmer_memory_t`.
///
Expand Down

0 comments on commit 204f06e

Please sign in to comment.