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

Function dfs_file_create

components/dfs/dfs_v2/src/dfs.c:255–268  ·  view source on GitHub ↗

* @brief Create and initialize a new file descriptor structure * * @return struct dfs_file* Pointer to the newly created file descriptor structure, * NULL if memory allocation failed */

Source from the content-addressed store, hash-verified

253 * NULL if memory allocation failed
254 */
255struct dfs_file* dfs_file_create(void)
256{
257 struct dfs_file *file;
258
259 file = (struct dfs_file *)rt_calloc(1, sizeof(struct dfs_file));
260 if (file)
261 {
262 file->magic = DFS_FD_MAGIC;
263 file->ref_count = 1;
264 rt_mutex_init(&file->pos_lock, "fpos", RT_IPC_FLAG_PRIO);
265 }
266
267 return file;
268}
269
270/**
271 * @brief Destroy and free a file descriptor structure

Callers 1

fdt_fd_newFunction · 0.85

Calls 2

rt_callocFunction · 0.85
rt_mutex_initFunction · 0.85

Tested by

no test coverage detected