[devhelp] DhLink: new(): check book DhLink type



commit 826e57e2a5e1f1f0855d225b7ceca832a5b578dd
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Dec 8 21:47:39 2017 +0100

    DhLink: new(): check book DhLink type

 src/dh-link.c |   13 +++++++------
 src/dh-link.h |    2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/dh-link.c b/src/dh-link.c
index b00d92b..f8bacfe 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -168,29 +168,30 @@ dh_link_new_book (const gchar *base_path,
 /**
  * dh_link_new:
  * @type: the #DhLinkType. Must be different than %DH_LINK_TYPE_BOOK.
- * @book: the book that the link is contained in.
+ * @book_link: the #DhLink of type %DH_LINK_TYPE_BOOK for the book that the link
+ *   is contained in.
  * @name: the name of the link.
- * @relative_url: the URL relative to the book @base_path. Can contain an
- * anchor.
+ * @relative_url: the URL relative to the book base path. Can contain an anchor.
  *
  * Returns: a new #DhLink.
  */
 DhLink *
 dh_link_new (DhLinkType   type,
-             DhLink      *book,
+             DhLink      *book_link,
              const gchar *name,
              const gchar *relative_url)
 {
         DhLink *link;
 
         g_return_val_if_fail (type != DH_LINK_TYPE_BOOK, NULL);
-        g_return_val_if_fail (book != NULL, NULL);
+        g_return_val_if_fail (book_link != NULL, NULL);
+        g_return_val_if_fail (book_link->type == DH_LINK_TYPE_BOOK, NULL);
         g_return_val_if_fail (name != NULL, NULL);
         g_return_val_if_fail (relative_url != NULL, NULL);
 
         link = dh_link_new_common (type, name, relative_url);
 
-        link->book.link = dh_link_ref (book);
+        link->book.link = dh_link_ref (book_link);
 
         return link;
 }
diff --git a/src/dh-link.h b/src/dh-link.h
index 68356fa..98f50cb 100644
--- a/src/dh-link.h
+++ b/src/dh-link.h
@@ -75,7 +75,7 @@ DhLink *     dh_link_new_book           (const gchar   *base_path,
                                          const gchar   *relative_url);
 
 DhLink *     dh_link_new                (DhLinkType     type,
-                                         DhLink        *book,
+                                         DhLink        *book_link,
                                          const gchar   *name,
                                          const gchar   *relative_url);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]