+/*
+ * Get the full hierarchical object name for an export, used for diagnostics.
+ * Currently, this does not include the package name (which is actually
+ * required for this to be a "full" name) as it's not yet passed to the
+ * deserialize method.
+ *
+ * Returns a buffer allocated by malloc on success, or NULL on failure.
+ */
+static char *get_obj_fullname(const struct upkg_export *e)
+{
+ size_t total_len = 0, len;
+ char *fullname;
+
+ for (const struct upkg_export *c = e; c; c = c->parent) {
+ len = strlen(c->name) + 1;
+ if (total_len > SIZE_MAX - len)
+ return NULL;
+ total_len += len;
+ }
+
+ fullname = malloc(total_len);
+ if (!fullname)
+ return NULL;
+
+ for (const struct upkg_export *c = e; c; c = c->parent) {
+ len = strlen(c->name);
+ assert(total_len > len);
+
+ total_len -= len + 1;
+ memcpy(fullname + total_len, c->name, len);
+ fullname[total_len + len] = c == e ? '\0' : '.';
+ }
+
+ return fullname;
+}
+