瀏覽代碼

Clarify behaviour of plug() by using intf_put() and intf_get().

tags/v0.9.3
Michael Brown 18 年之前
父節點
當前提交
a90a9adbd7
共有 2 個文件被更改,包括 22 次插入3 次删除
  1. 2
    3
      src/core/interface.c
  2. 20
    0
      src/include/gpxe/interface.h

+ 2
- 3
src/core/interface.c 查看文件

@@ -38,9 +38,8 @@
38 38
  * interface into a null interface.
39 39
  */
40 40
 void plug ( struct interface *intf, struct interface *dest ) {
41
-	ref_put ( intf->dest->refcnt );
42
-	intf->dest = dest;
43
-	ref_get ( intf->dest->refcnt );
41
+	intf_put ( intf->dest );
42
+	intf->dest = intf_get ( dest );
44 43
 }
45 44
 
46 45
 /**

+ 20
- 0
src/include/gpxe/interface.h 查看文件

@@ -28,6 +28,26 @@ struct interface {
28 28
 	struct refcnt *refcnt;
29 29
 };
30 30
 
31
+/**
32
+ * Increment reference count on an interface
33
+ *
34
+ * @v intf		Interface
35
+ * @ret intf		Interface
36
+ */
37
+static inline struct interface * intf_get ( struct interface *intf ) {
38
+	ref_get ( intf->refcnt );
39
+	return intf;
40
+}
41
+
42
+/**
43
+ * Decrement reference count on an interface
44
+ *
45
+ * @v intf		Interface
46
+ */
47
+static inline void intf_put ( struct interface *intf ) {
48
+	ref_put ( intf->refcnt );
49
+}
50
+
31 51
 extern void plug ( struct interface *intf, struct interface *dest );
32 52
 extern void plug_plug ( struct interface *a, struct interface *b );
33 53
 

Loading…
取消
儲存