mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 13:00:39 +03:00
[refcnt] Add ref_init() wrapper function
Standardise on using ref_init() to initialise an embedded reference count, to match the coding style used by other embedded objects. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -264,7 +264,7 @@ int create_downloader ( struct job_interface *job, struct image *image,
|
||||
downloader = zalloc ( sizeof ( *downloader ) );
|
||||
if ( ! downloader )
|
||||
return -ENOMEM;
|
||||
downloader->refcnt.free = downloader_free;
|
||||
ref_init ( &downloader->refcnt, downloader_free );
|
||||
job_init ( &downloader->job, &downloader_job_operations,
|
||||
&downloader->refcnt );
|
||||
xfer_init ( &downloader->xfer, &downloader_xfer_operations,
|
||||
|
||||
@@ -59,6 +59,7 @@ static int hw_open ( struct xfer_interface *xfer, struct uri *uri __unused ) {
|
||||
hw = zalloc ( sizeof ( *hw ) );
|
||||
if ( ! hw )
|
||||
return -ENOMEM;
|
||||
ref_init ( &hw->refcnt, NULL );
|
||||
xfer_init ( &hw->xfer, &hw_xfer_operations, &hw->refcnt );
|
||||
process_init ( &hw->process, hw_step, &hw->refcnt );
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ struct image * alloc_image ( void ) {
|
||||
|
||||
image = zalloc ( sizeof ( *image ) );
|
||||
if ( image ) {
|
||||
image->refcnt.free = free_image;
|
||||
ref_init ( &image->refcnt, free_image );
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ int open ( const char *uri_string ) {
|
||||
file = zalloc ( sizeof ( *file ) );
|
||||
if ( ! file )
|
||||
return -ENOMEM;
|
||||
file->refcnt.free = posix_file_free;
|
||||
ref_init ( &file->refcnt, posix_file_free );
|
||||
file->fd = fd;
|
||||
file->rc = -EINPROGRESS;
|
||||
xfer_init ( &file->xfer, &posix_file_xfer_operations,
|
||||
|
||||
@@ -121,6 +121,7 @@ static int numeric_resolv ( struct resolv_interface *resolv,
|
||||
numeric = zalloc ( sizeof ( *numeric ) );
|
||||
if ( ! numeric )
|
||||
return -ENOMEM;
|
||||
ref_init ( &numeric->refcnt, NULL );
|
||||
resolv_init ( &numeric->resolv, &null_resolv_ops, &numeric->refcnt );
|
||||
process_init ( &numeric->process, numeric_step, &numeric->refcnt );
|
||||
memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
|
||||
@@ -256,6 +257,7 @@ int resolv ( struct resolv_interface *resolv, const char *name,
|
||||
mux = zalloc ( sizeof ( *mux ) + name_len );
|
||||
if ( ! mux )
|
||||
return -ENOMEM;
|
||||
ref_init ( &mux->refcnt, NULL );
|
||||
resolv_init ( &mux->parent, &null_resolv_ops, &mux->refcnt );
|
||||
resolv_init ( &mux->child, &resolv_mux_child_ops, &mux->refcnt );
|
||||
mux->resolver = table_start ( RESOLVERS );
|
||||
@@ -389,6 +391,7 @@ int xfer_open_named_socket ( struct xfer_interface *xfer, int semantics,
|
||||
named = zalloc ( sizeof ( *named ) );
|
||||
if ( ! named )
|
||||
return -ENOMEM;
|
||||
ref_init ( &named->refcnt, NULL );
|
||||
xfer_init ( &named->xfer, &named_xfer_ops, &named->refcnt );
|
||||
resolv_init ( &named->resolv, &named_resolv_ops, &named->refcnt );
|
||||
named->semantics = semantics;
|
||||
|
||||
Reference in New Issue
Block a user