Browse Source

[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 years ago
parent
commit
719ba316df
3 changed files with 14 additions and 11 deletions
  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 View File

76
 		free ( refcnt );
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 View File

13
 #include <ipxe/uaccess.h>
13
 #include <ipxe/uaccess.h>
14
 #include <ipxe/init.h>
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
 /* Raw image data for all embedded images */
16
 /* Raw image data for all embedded images */
27
 #undef EMBED
17
 #undef EMBED
28
 #define EMBED( _index, _path, _name )					\
18
 #define EMBED( _index, _path, _name )					\
41
 /* Image structures for all embedded images */
31
 /* Image structures for all embedded images */
42
 #undef EMBED
32
 #undef EMBED
43
 #define EMBED( _index, _path, _name ) {					\
33
 #define EMBED( _index, _path, _name ) {					\
44
-	.refcnt = REF_INIT ( embedded_image_free ),			\
34
+	.refcnt = REF_INIT ( ref_no_free ),				\
45
 	.name = _name,							\
35
 	.name = _name,							\
46
 	.data = ( userptr_t ) ( embedded_image_ ## _index ## _data ),	\
36
 	.data = ( userptr_t ) ( embedded_image_ ## _index ## _data ),	\
47
 	.len = ( size_t ) embedded_image_ ## _index ## _len,		\
37
 	.len = ( size_t ) embedded_image_ ## _index ## _len,		\

+ 1
- 0
src/include/ipxe/refcnt.h View File

77
 
77
 
78
 extern struct refcnt * ref_get ( struct refcnt *refcnt );
78
 extern struct refcnt * ref_get ( struct refcnt *refcnt );
79
 extern void ref_put ( struct refcnt *refcnt );
79
 extern void ref_put ( struct refcnt *refcnt );
80
+extern void ref_no_free ( struct refcnt *refcnt );
80
 
81
 
81
 #endif /* _IPXE_REFCNT_H */
82
 #endif /* _IPXE_REFCNT_H */

Loading…
Cancel
Save