Skip to content

uint32_t instead of int64_t as return type for GetMemorySegmentByteOffset - #2432

Merged
tlively merged 2 commits into
WebAssembly:masterfrom
COFFEETALES:fetch-item-by-idx
Nov 13, 2019
Merged

tlively merged 2 commits into
WebAssembly:masterfrom
COFFEETALES:fetch-item-by-idx

Conversation

@COFFEETALES

Copy link
Copy Markdown
Contributor

and minor test fixes

@tlively tlively left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just a few small readability nits on the test.

Comment thread test/example/c-api-kitchen-sink.c Outdated
}

BinaryenAddGlobal(module, "a-global", BinaryenTypeInt32(), 0, makeInt32(module, 125));
const int32_t expected_offsets[] = { 10, 125 };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const int32_t expected_offsets[] = { 10, 125 };
const uint32_t expected_offsets[] = { 10, 125 };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more readable to group all the static data about the segments here at the top instead of mixing it in with binaryen API calls.

Comment thread test/example/c-api-kitchen-sink.c Outdated
BinaryenSetMemory(module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 0);

for (i = 0; i < BinaryenGetNumMemorySegments(module) ; i++) {
char out[15] = {0};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char out[15] = {0};
char out[15] = {};

Comment thread test/example/c-api-kitchen-sink.c Outdated
assert(BinaryenGetMemorySegmentByteOffset(module, i) == (0==i?10:125));
assert(BinaryenGetMemorySegmentByteOffset(module, i) == expected_offsets[i]);
assert(BinaryenGetMemorySegmentByteLength(module, i) == segmentSizes[i]);
BinaryenCopyMemorySegmentData(module, i, &out[0]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BinaryenCopyMemorySegmentData(module, i, &out[0]);
BinaryenCopyMemorySegmentData(module, i, out);

Comment thread test/example/c-api-kitchen-sink.c Outdated
else {
assert(0 == strcmp("segment data 2", &out[0]));
}
assert(0 == strcmp(segments[i], &out[0]));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(0 == strcmp(segments[i], &out[0]));
assert(0 == strcmp(segments[i], out));

@tlively tlively left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants