Skip to content

Commit 1281dab

Browse files
peterhuenesunfishcode
authored andcommitted
Make __wasi_args_get and __wasi_environ_get docs more explicit. (#128)
This commit updates the documentation for `__wasi_args_get` and `__wasi_environ_get` to make it explicit that it is the caller's responsibility to allocate a terminating NULL pointer, if necessary. Fixes #27.
1 parent a7d17ba commit 1281dab

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

phases/ephemeral/docs/wasi_ephemeral_preview.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,22 @@ modules so that embedders need not implement all of it.
117117

118118
Read command-line argument data.
119119

120-
The sizes of the buffers should match that returned by [`__wasi_args_sizes_get()`](#args_sizes_get).
121-
122120
Inputs:
123121

124122
- <a href="#args_get.argv" name="args_get.argv"></a><code>char \*\*<strong>argv</strong></code>
125123

126124
A pointer to a buffer to write the argument pointers.
127125

126+
The count of elements for the buffer should be at least the value of `argc` returned by [`__wasi_args_sizes_get()`](#args_sizes_get).
127+
128+
The caller of `__wasi_args_get()` is responsible for allocating an additional element for a terminating NULL pointer, if necessary.
129+
128130
- <a href="#args_get.argv_buf" name="args_get.argv_buf"></a><code>char \*<strong>argv\_buf</strong></code>
129131

130132
A pointer to a buffer to write the argument string data.
131133

134+
The size of this buffer should be the value of `argv_buf_size` returned by [`__wasi_args_sizes_get()`](#args_sizes_get).
135+
132136
### <a href="#args_sizes_get" name="args_sizes_get"></a>`__wasi_args_sizes_get()`
133137

134138
Return command-line argument data sizes.
@@ -192,21 +196,25 @@ Outputs:
192196

193197
Read environment variable data.
194198

195-
The sizes of the buffers should match that returned by [`__wasi_environ_sizes_get()`](#environ_sizes_get).
196-
197199
Inputs:
198200

199201
- <a href="#environ_get.environ" name="environ_get.environ"></a><code>char \*\*<strong>environ</strong></code>
200202

201203
A pointer to a buffer to write the environment variable pointers.
202204

205+
The count of elements for the buffer should be at least the value of `environ_count` returned by [`__wasi_environ_sizes_get()`](#environ_sizes_get).
206+
207+
The caller of `__wasi_environ_get()` is responsible for allocating an additional element for a terminating NULL pointer, if necessary.
208+
203209
- <a href="#environ_get.environ_buf" name="environ_get.environ_buf"></a><code>char \*<strong>environ\_buf</strong></code>
204210

205211
A pointer to a buffer to write the environment variable string data.
206212

213+
The size of this buffer should be the value of `environ_buf_size` returned by [`__wasi_environ_sizes_get()`](#environ_sizes_get).
214+
207215
### <a href="#environ_sizes_get" name="environ_sizes_get"></a>`__wasi_environ_sizes_get()`
208216

209-
Return command-line argument data sizes.
217+
Return enviroment variable data sizes.
210218

211219
Outputs:
212220

0 commit comments

Comments
 (0)