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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -