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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -