Have I to allocate memory before using this system calls? -
i see functions called without allocate memory path
, dir
, buf
, name
.
char *getcwd(char *path, size_t size); struct dirent *readdir(dir *dir); int stat(const char *file_name, struct stat *buf); dir *opendir(const char *name);
why? functions allocate memory? have use free() after using them?
thank you!
they pseudo-code examples. aren't going show how allocate memory them you, it's assumed know how that.
and yes, need free memory allocate, otherwise you'll have memory leak.
all examples take pointers, indicate operate on memory have allocated, not allocate you.
Comments
Post a Comment