A
ArifulHossain tuhin
I have used many OSS libraries which have a common structure like the following:
They have init function which takes a pointer to pointer to the module data structure like this:
module_init(struct module_ds ** p,.....);
And usage example is like following:
struct module_ds * p;
p = NULL;
module_init(&p,....);
etc.
Now i'm wondering why they do it this way? if i pass a plain pointer then it should be ok to declare a local pointer and allocate and initialize it. after initialization it can be returned by the fuction.
but they always have a void type.
Even if they remain "void" still it should be possible to allocate, and initialize a local pointer and assign it to a plain pointer comes as a argument?
Or "local" pointer is key here?
Thanks in advance.
They have init function which takes a pointer to pointer to the module data structure like this:
module_init(struct module_ds ** p,.....);
And usage example is like following:
struct module_ds * p;
p = NULL;
module_init(&p,....);
etc.
Now i'm wondering why they do it this way? if i pass a plain pointer then it should be ok to declare a local pointer and allocate and initialize it. after initialization it can be returned by the fuction.
but they always have a void type.
Even if they remain "void" still it should be possible to allocate, and initialize a local pointer and assign it to a plain pointer comes as a argument?
Or "local" pointer is key here?
Thanks in advance.