ソースを参照

[refcnt] Add ref_no_free handler

Since more reference-counted structures than embedded images might
want to mark themselves unfreeable, expose a dummy ref_no_free().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Joshua Oreman 15年前
コミット
719ba316df
3個のファイルの変更14行の追加11行の削除
  1. 12
    0
      src/core/refcnt.c
  2. 1
    11
      src/image/embedded.c
  3. 1
    0
      src/include/ipxe/refcnt.h

+ 12
- 0
src/core/refcnt.c ファイルの表示

@@ -76,3 +76,15 @@ void ref_put ( struct refcnt *refcnt ) {
76 76
 		free ( refcnt );
77 77
 	}
78 78
 }
79
+
80
+/**
81
+ * Do not free reference-counted object
82
+ *
83
+ * @v refcnt		Reference counter
84
+ *
85
+ * This is meant for initializing a reference counter structure in a
86
+ * statically allocated object.
87
+ */
88
+void ref_no_free ( struct refcnt *refcnt __unused ) {
89
+	/* Do nothing */
90
+}

+ 1
- 11
src/image/embedded.c ファイルの表示

@@ -13,16 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
13 13
 #include <ipxe/uaccess.h>
14 14
 #include <ipxe/init.h>
15 15
 
16
-/**
17
- * Free embedded image
18
- *
19
- * @v refcnt		Reference counter
20
- */
21
-static void __attribute__ (( unused ))
22
-embedded_image_free ( struct refcnt *refcnt __unused ) {
23
-	/* Do nothing */
24
-}
25
-
26 16
 /* Raw image data for all embedded images */
27 17
 #undef EMBED
28 18
 #define EMBED( _index, _path, _name )					\
@@ -41,7 +31,7 @@ EMBED_ALL
41 31
 /* Image structures for all embedded images */
42 32
 #undef EMBED
43 33
 #define EMBED( _index, _path, _name ) {					\
44
-	.refcnt = REF_INIT ( embedded_image_free ),			\
34
+	.refcnt = REF_INIT ( ref_no_free ),				\
45 35
 	.name = _name,							\
46 36
 	.data = ( userptr_t ) ( embedded_image_ ## _index ## _data ),	\
47 37
 	.len = ( size_t ) embedded_image_ ## _index ## _len,		\

+ 1
- 0
src/include/ipxe/refcnt.h ファイルの表示

@@ -77,5 +77,6 @@ ref_init ( struct refcnt *refcnt,
77 77
 
78 78
 extern struct refcnt * ref_get ( struct refcnt *refcnt );
79 79
 extern void ref_put ( struct refcnt *refcnt );
80
+extern void ref_no_free ( struct refcnt *refcnt );
80 81
 
81 82
 #endif /* _IPXE_REFCNT_H */

読み込み中…
キャンセル
保存