On 4/18/05, David Farning <dfarning@xxxxxxxxxxxxx> wrote: > I am working on pulling some rpm info out of a headerEntry but, I am > running into trouble with RPMTAG_PROVIDEFLAGS. The snippet below shows > how I am pulling out the provides and sticking it in a struct called > pkg_node_exp. (The printf statements show that the flags are being > pulled out correctly.) > > headerGetEntry (hd, RPMTAG_PROVIDENAME, &type, (void **) &arg, &count); > pkg_node_exp->provide_name = (char **) arg; > > headerGetEntry (hd, RPMTAG_PROVIDEFLAGS, &type, (void **) &flags, > &count); > pkg_node_exp->provide_flags = (int_32 *)flags; > > printf ("\t count = %d\n", count); > > printf ("\t %d\n", pkg_node_exp->provide_flags[0]); > printf ("\t %d\n", pkg_node_exp->provide_flags[1]); > > headerGetEntry (hd, RPMTAG_PROVIDEVERSION, &type, (void **) &arg, > &count); > pkg_node_exp->provide_version = (char **) arg; > pkg_node_exp->provide_count = count; > > Later when I try to use pkg_node_exp via > > if (pkg_node_exp->provide_count > 0) > { > printf ("Provides\n"); > printf ("\t count = %d\n", pkg_node_exp->provide_count); > for (i = 0; i < pkg_node_exp->provide_count; i++) > printf ("\t %s %i %s\n", > pkg_node_exp->provide_name[i], > pkg_node_exp->provide_flags[i], > pkg_node_exp->provide_version[i]); > } > > I get a segfault when when printing the provide_flags, if I comment the > line out the "pkg_node_exp->provide_flags[i]," line, the names and > versions are printed correctly. Are arrays of type int_32 being malloced > differently the arrays of char*s. > I'd have to see all the code, but I think you might need to call headerLink() with the header after you have gathered all your info, and then headerUnlink (or is it headerFree?) once the info is used. The reason being is that rpm otherwise may reclaim the header. Now if all your code is in the same subroutine and your not calling headerUnlink() then this is not likely, but if your gathering the info in one sub, and then using it in another sub, then you definately need to do the headerLink() stuff. That said, if instead of doing a simple assignment you copy the data you might be better off (less memory efficient and wastes a few cycles, but at the end of the day more reliable). Reason I say this is that since your already decomposing the header "object" you might as well sever all link between it and your structure/object. Cheers...james > Thanks > -dtf > > _______________________________________________ > Rpm-list mailing list > Rpm-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/rpm-list > _______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list