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]); }
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 James,
It took we awhile to get back to this, but I ended up completly severing the header from my stucture with--
pkg_node_exp->file_flags = malloc (sizeof (int_32) * count); memcpy (pkg_node_exp->file_flags, flags, (sizeof (int_32) * count));
then freed the header with--
headerFree (hd);
The run time increased ~.5% but the memory footprint also decreased slightly.
-dtf
_______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list