MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / fdt_fd_release

Function fdt_fd_release

components/dfs/dfs_v2/src/dfs.c:350–369  ·  view source on GitHub ↗

* @brief Release a file descriptor from the file descriptor table * * @param[in,out] fdt Pointer to the file descriptor table * @param[in] fd The file descriptor to be released */

Source from the content-addressed store, hash-verified

348 * @param[in] fd The file descriptor to be released
349 */
350void fdt_fd_release(struct dfs_fdtable *fdt, int fd)
351{
352 if (fd < fdt->maxfd)
353 {
354 struct dfs_file *file;
355
356 file = fdt_get_file(fdt, fd);
357
358 if (file && file->ref_count == 1)
359 {
360 dfs_file_destroy(file);
361 }
362 else
363 {
364 rt_atomic_sub(&(file->ref_count), 1);
365 }
366
367 fdt->fds[fd] = RT_NULL;
368 }
369}
370
371/**
372 * @ingroup group_fs_file_descriptor

Callers 3

fd_releaseFunction · 0.70
dfs_fdtable_drop_fdFunction · 0.70
dfs_dup_fromFunction · 0.70

Calls 2

fdt_get_fileFunction · 0.85
dfs_file_destroyFunction · 0.85

Tested by

no test coverage detected