summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael Brown2010-06-15 18:33:23 +0200
committerMichael Brown2010-06-22 15:26:40 +0200
commit4bfd5b52c1fae75eb0449af626ec69543f9334fa (patch)
tree297bc75308e763df909fb0733c0ca2ac109ebcbc /src/core
parent[pcnet32] Replace pcnet32 with native driver (diff)
downloadipxe-4bfd5b52c1fae75eb0449af626ec69543f9334fa.tar.gz
ipxe-4bfd5b52c1fae75eb0449af626ec69543f9334fa.tar.xz
ipxe-4bfd5b52c1fae75eb0449af626ec69543f9334fa.zip
[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>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/downloader.c2
-rw-r--r--src/core/hw.c1
-rw-r--r--src/core/image.c2
-rw-r--r--src/core/posix_io.c2
-rw-r--r--src/core/resolv.c3
5 files changed, 7 insertions, 3 deletions
diff --git a/src/core/downloader.c b/src/core/downloader.c
index 9285efa20..5499ddaba 100644
--- a/src/core/downloader.c
+++ b/src/core/downloader.c
@@ -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,
diff --git a/src/core/hw.c b/src/core/hw.c
index f8dc6be4a..b4a190271 100644
--- a/src/core/hw.c
+++ b/src/core/hw.c
@@ -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 );
diff --git a/src/core/image.c b/src/core/image.c
index c6ef71f47..f530cafd4 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -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;
}
diff --git a/src/core/posix_io.c b/src/core/posix_io.c
index 05077c8b2..2ecb15410 100644
--- a/src/core/posix_io.c
+++ b/src/core/posix_io.c
@@ -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,
diff --git a/src/core/resolv.c b/src/core/resolv.c
index 9c96b9fca..ec7a556ce 100644
--- a/src/core/resolv.c
+++ b/src/core/resolv.c
@@ -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;