]> git.draconx.ca Git - upkg.git/commitdiff
uobject: Include package names in package fullname.
authorNick Bowler <nbowler@draconx.ca>
Wed, 16 May 2012 00:38:47 +0000 (20:38 -0400)
committerNick Bowler <nbowler@draconx.ca>
Wed, 16 May 2012 00:38:47 +0000 (20:38 -0400)
Now that we have access to the package in deserialize, we can include
its name.

src/uobject/uobject.c

index df875b2ac8f608986bba0223602f90ee93190860..b8c24796dafd601c7669482c0d78338f6ffd317f 100644 (file)
@@ -314,17 +314,17 @@ static int deserialize(UObject *uo)
 
 /*
  * 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.
+ * The package name is passed in pname.
  *
  * Returns a buffer allocated by malloc on success, or NULL on failure.
  */
-static char *get_obj_fullname(const struct upkg_export *e)
+static char *get_obj_fullname(const char *pname, const struct upkg_export *e)
 {
-       size_t total_len = 0, len;
+       size_t total_len = strlen(pname) + 1, len;
        char *fullname;
 
+       assert(e != NULL);
+
        for (const struct upkg_export *c = e; c; c = c->parent) {
                len = strlen(c->name) + 1;
                if (total_len > SIZE_MAX - len)
@@ -345,6 +345,10 @@ static char *get_obj_fullname(const struct upkg_export *e)
                fullname[total_len + len] = c == e ? '\0' : '.';
        }
 
+       assert(total_len == strlen(pname)+1);
+       memcpy(fullname, pname, total_len-1);
+       fullname[total_len-1] = '.';
+
        return fullname;
 }
 
@@ -371,7 +375,7 @@ int u_object_deserialize(GObject *obj, GTypeModule *pkg, unsigned long idx)
        e = upkg_get_export(upkg, idx);
        if (!e)
                return -1;
-       uo->pkg_name = get_obj_fullname(e);
+       uo->pkg_name = get_obj_fullname(pkg->name, e);
        if (!uo->pkg_name)
                return -1;