MCPcopy Create free account
hub / github.com/apache/nuttx / envpath_init

Function envpath_init

libs/libc/misc/lib_envpath.c:85–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 ****************************************************************************/
84
85ENVPATH_HANDLE envpath_init(FAR const char *name)
86{
87 FAR struct envpath_s *envpath;
88 FAR char *path;
89 size_t size;
90
91 /* Get the value of the PATH variable */
92
93 path = getenv(name);
94 if (!path)
95 {
96 /* getenv() will return a NULL value if the PATH variable does not
97 * exist in the environment.
98 */
99
100 return NULL;
101 }
102
103 /* Allocate a container for the PATH variable contents */
104
105 size = strlen(path) + 1;
106 envpath = (FAR struct envpath_s *)
107 lib_malloc(SIZEOF_ENVPATH_S(size));
108
109 if (!envpath)
110 {
111 /* Ooops.. we are out of memory */
112
113 return NULL;
114 }
115
116 /* Populate the container */
117
118 strlcpy(envpath->path, path, size);
119 envpath->next = envpath->path;
120
121 /* And return the containing cast to an opaque handle */
122
123 return envpath;
124}
125
126/****************************************************************************
127 * Name: envpath_next

Callers 2

dlopenFunction · 0.85
load_moduleFunction · 0.85

Calls 3

getenvFunction · 0.85
strlenFunction · 0.50
strlcpyFunction · 0.50

Tested by

no test coverage detected