Allan McRae wrote:
Before I resubmit an updated patch with all the functions updated, is this function better? Specifically, do I free vdata correctly?
int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg) { void *vdata = NULL; handle->noupgrade = alpm_list_remove(handle->noupgrade, pkg, _alpm_str_cmp, &vdata); if(vdata != NULL) { FREELIST(vdata); return 1; } return 0; }
If vdata is just a string (not a list), just do : free(vdata); Or you can also do FREE(vdata), which is equivalent to: free(vdata); vdata = NULL; Also, following pacman syntax, it would rather look like : int SYMEXPORT alpm_option_remove_noupgrade(const char *pkg) { void *vdata = NULL; handle->noupgrade = alpm_list_remove(handle->noupgrade, pkg, _alpm_str_cmp, &vdata); if(vdata != NULL) { FREE(vdata); return(1); } return(0); }