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

Function alloc_device_name

components/lwp/terminal/tty_device.c:24–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23#define TTY_NAME_PREFIX "tty"
24static char *alloc_device_name(const char *name)
25{
26 char *tty_dev_name;
27 long name_buf_len = (sizeof(TTY_NAME_PREFIX) - 1) /* raw prefix */
28 + rt_strlen(name) /* custom name */
29 + 1; /* tailing \0 */
30
31 tty_dev_name = rt_malloc(name_buf_len);
32 if (tty_dev_name)
33 sprintf(tty_dev_name, "%s%s", TTY_NAME_PREFIX, name);
34 return tty_dev_name;
35}
36
37/* character device for tty */
38#ifdef RT_USING_DEVICE_OPS

Callers 1

lwp_tty_registerFunction · 0.70

Calls 2

rt_strlenFunction · 0.85
rt_mallocFunction · 0.85

Tested by

no test coverage detected