Hello,
I'm looking at the sources for functions ps_free(ps), cmd_ln_free_r(config), ad_close(ad), and fclose(fd). I'm trying to make sure that all of those pointers are properly freed, but so far, I've only found that cmd_ln_free_r actually free what's passed to it, and not just the pointers it contains. Can anyone tell me if I'm supposed to manually free the rest, or if I've just missed them?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is not quite clear what are you asking about. You need to explain more. In general, you need to free what you allocated before. All functions listed above properly release corresponding objects. You can use valgrind to check leaks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry if I worded it badly. For example, if I call ps_free(ps), does this actually free ps? Looking at the source code for ps_free, I see that all of pointers that is referenced by ps, such as ps->config and ps->dict do get freed, but I couldn't pinpoint exactly where ps itself gets freed.
EDIT: Sorry, I did find it for ps_free. But not for ad_close and fclose.
Last edit: Ralph Kim 2016-06-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm looking at the sources for functions ps_free(ps), cmd_ln_free_r(config), ad_close(ad), and fclose(fd). I'm trying to make sure that all of those pointers are properly freed, but so far, I've only found that cmd_ln_free_r actually free what's passed to it, and not just the pointers it contains. Can anyone tell me if I'm supposed to manually free the rest, or if I've just missed them?
It is not quite clear what are you asking about. You need to explain more. In general, you need to free what you allocated before. All functions listed above properly release corresponding objects. You can use valgrind to check leaks.
Sorry if I worded it badly. For example, if I call ps_free(ps), does this actually free ps? Looking at the source code for ps_free, I see that all of pointers that is referenced by ps, such as ps->config and ps->dict do get freed, but I couldn't pinpoint exactly where ps itself gets freed.
EDIT: Sorry, I did find it for ps_free. But not for ad_close and fclose.
Last edit: Ralph Kim 2016-06-08
ad_close frees the pointer as well, you can look in sphinxbase sources. fclose also frees the pointer, it is a system library call.
Thank you for the quick replies. And sorry about the silly questions.