- /* 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) {
+ struct upkg_priv *pkg = (struct upkg_priv *)pub;
+
+ /* 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->pub.export_count; i++) {
+ struct upkg_export_priv *e = &pkg->exports[i];
+
+ /* Assertion: an object's package is an export. */
+ format_assert(e->pub.package >= 0, continue);
+ if (e->pub.package == package
+ && strcmp(e->pub.name, name) == 0) {