return pkg->priv->names[idx].name;
}
-long upkg_export_find(struct upkg *pkg, const char *name)
+long upkg_export_find(struct upkg *pkg, long parent, const char *name)
{
- /* This is wrong.
- * Export names are not necessarily unique within a package. */
- for (unsigned i = 0; i < pkg->export_count; i++) {
- struct upkg_export *export = &pkg->priv->exports[i];
- if (strcmp(export->name, name) == 0) {
+ /* This only makes sense if the assertion below is not violated. */
+ long package = parent < 0 ? 0 : parent + 1;
+
+ for (unsigned long i = 0; i < pkg->export_count; i++) {
+ struct upkg_export *e = &pkg->priv->exports[i];
+
+ /* Assertion: an object's package is an export. */
+ format_assert(e->package >= 0, continue);
+ if (e->package == package && strcmp(e->name, name) == 0) {
return i;
}
}