Lines Matching refs:table
19 struct uvwasi_fd_table_t* table,
38 table,
60 struct uvwasi_fd_table_t* table,
119 uv_rwlock_wrlock(&table->rwlock);
121 /* Check that there is room for a new item. If there isn't, grow the table. */
122 if (table->used >= table->size) {
123 new_size = table->size * 2;
124 new_fds = uvwasi__realloc(uvwasi, table->fds, new_size * sizeof(*new_fds));
131 for (i = table->size; i < new_size; ++i)
134 index = table->size;
135 table->fds = new_fds;
136 table->size = new_size;
138 /* The table is big enough, so find an empty slot for the new data. */
140 for (i = 0; i < table->size; ++i) {
141 if (table->fds[i] == NULL) {
156 table->fds[index] = entry;
180 table->used++;
183 uv_rwlock_wrunlock(&table->rwlock);
190 struct uvwasi_fd_table_t* table;
198 table = uvwasi__malloc(uvwasi, sizeof(*table));
199 if (table == NULL)
202 table->used = 0;
203 table->size = options->fd_table_size;
204 table->fds = uvwasi__calloc(uvwasi,
207 if (table->fds == NULL) {
208 uvwasi__free(uvwasi, table);
212 r = uv_rwlock_init(&table->rwlock);
215 uvwasi__free(uvwasi, table->fds);
216 uvwasi__free(uvwasi, table);
221 err = uvwasi__insert_stdio(uvwasi, table, options->in, 0, "<stdin>");
225 err = uvwasi__insert_stdio(uvwasi, table, options->out, 1, "<stdout>");
229 err = uvwasi__insert_stdio(uvwasi, table, options->err, 2, "<stderr>");
233 uvwasi->fds = table;
236 uvwasi_fd_table_free(uvwasi, table);
241 void uvwasi_fd_table_free(uvwasi_t* uvwasi, struct uvwasi_fd_table_t* table) {
245 if (uvwasi == NULL || table == NULL)
248 for (i = 0; i < table->size; i++) {
249 entry = table->fds[i];
258 if (table->fds != NULL) {
259 uvwasi__free(uvwasi, table->fds);
260 table->fds = NULL;
261 table->size = 0;
262 table->used = 0;
263 uv_rwlock_destroy(&table->rwlock);
266 uvwasi__free(uvwasi, table);
271 struct uvwasi_fd_table_t* table,
280 if (table == NULL || path == NULL || real_path == NULL)
295 table,
309 struct uvwasi_fd_table_t* table,
311 if (table == NULL || sock == NULL)
315 table,
328 uvwasi_errno_t uvwasi_fd_table_get(struct uvwasi_fd_table_t* table,
335 if (table == NULL)
338 uv_rwlock_wrlock(&table->rwlock);
339 err = uvwasi_fd_table_get_nolock(table,
344 uv_rwlock_wrunlock(&table->rwlock);
350 but does not lock the file descriptor table like uvwasi_fd_table_get() does.
352 uvwasi_errno_t uvwasi_fd_table_get_nolock(struct uvwasi_fd_table_t* table,
359 if (table == NULL || wrap == NULL)
362 if (id >= table->size)
365 entry = table->fds[id];
383 struct uvwasi_fd_table_t* table,
387 if (table == NULL)
390 if (id >= table->size)
393 entry = table->fds[id];
400 table->fds[id] = NULL;
401 table->used--;
407 struct uvwasi_fd_table_t* table,
416 if (uvwasi == NULL || table == NULL)
422 uv_rwlock_wrlock(&table->rwlock);
424 if (dst >= table->size || src >= table->size) {
429 dst_entry = table->fds[dst];
430 src_entry = table->fds[src];
451 /* Move the source entry to the destination slot in the table. */
452 table->fds[dst] = table->fds[src];
453 table->fds[dst]->id = dst;
454 uv_mutex_unlock(&table->fds[dst]->mutex);
455 table->fds[src] = NULL;
456 table->used--;
465 uv_rwlock_wrunlock(&table->rwlock);
470 uvwasi_errno_t uvwasi_fd_table_lock(struct uvwasi_fd_table_t* table) {
471 if (table == NULL)
474 uv_rwlock_wrlock(&table->rwlock);
479 uvwasi_errno_t uvwasi_fd_table_unlock(struct uvwasi_fd_table_t* table) {
480 if (table == NULL)
483 uv_rwlock_wrunlock(&table->rwlock);