mirror of https://github.com/ipxe/ipxe.git
[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>pull/1/head
parent
b707f15ecb
commit
719ba316df
|
@ -76,3 +76,15 @@ void ref_put ( struct refcnt *refcnt ) {
|
||||||
free ( refcnt );
|
free ( refcnt );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not free reference-counted object
|
||||||
|
*
|
||||||
|
* @v refcnt Reference counter
|
||||||
|
*
|
||||||
|
* This is meant for initializing a reference counter structure in a
|
||||||
|
* statically allocated object.
|
||||||
|
*/
|
||||||
|
void ref_no_free ( struct refcnt *refcnt __unused ) {
|
||||||
|
/* Do nothing */
|
||||||
|
}
|
||||||
|
|
|
@ -13,16 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include <ipxe/uaccess.h>
|
#include <ipxe/uaccess.h>
|
||||||
#include <ipxe/init.h>
|
#include <ipxe/init.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* Free embedded image
|
|
||||||
*
|
|
||||||
* @v refcnt Reference counter
|
|
||||||
*/
|
|
||||||
static void __attribute__ (( unused ))
|
|
||||||
embedded_image_free ( struct refcnt *refcnt __unused ) {
|
|
||||||
/* Do nothing */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Raw image data for all embedded images */
|
/* Raw image data for all embedded images */
|
||||||
#undef EMBED
|
#undef EMBED
|
||||||
#define EMBED( _index, _path, _name ) \
|
#define EMBED( _index, _path, _name ) \
|
||||||
|
@ -41,7 +31,7 @@ EMBED_ALL
|
||||||
/* Image structures for all embedded images */
|
/* Image structures for all embedded images */
|
||||||
#undef EMBED
|
#undef EMBED
|
||||||
#define EMBED( _index, _path, _name ) { \
|
#define EMBED( _index, _path, _name ) { \
|
||||||
.refcnt = REF_INIT ( embedded_image_free ), \
|
.refcnt = REF_INIT ( ref_no_free ), \
|
||||||
.name = _name, \
|
.name = _name, \
|
||||||
.data = ( userptr_t ) ( embedded_image_ ## _index ## _data ), \
|
.data = ( userptr_t ) ( embedded_image_ ## _index ## _data ), \
|
||||||
.len = ( size_t ) embedded_image_ ## _index ## _len, \
|
.len = ( size_t ) embedded_image_ ## _index ## _len, \
|
||||||
|
|
|
@ -77,5 +77,6 @@ ref_init ( struct refcnt *refcnt,
|
||||||
|
|
||||||
extern struct refcnt * ref_get ( struct refcnt *refcnt );
|
extern struct refcnt * ref_get ( struct refcnt *refcnt );
|
||||||
extern void ref_put ( struct refcnt *refcnt );
|
extern void ref_put ( struct refcnt *refcnt );
|
||||||
|
extern void ref_no_free ( struct refcnt *refcnt );
|
||||||
|
|
||||||
#endif /* _IPXE_REFCNT_H */
|
#endif /* _IPXE_REFCNT_H */
|
||||||
|
|
Loading…
Reference in New Issue