summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/libio.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src/libio.c')
-rw-r--r--cpukit/libcsupport/src/libio.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 26fa7b2f67..0abb082a66 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -108,14 +108,21 @@ int rtems_libio_to_fcntl_flags( unsigned int flags )
rtems_libio_t *rtems_libio_allocate( void )
{
- rtems_libio_t *iop = NULL;
+ rtems_libio_t *iop;
rtems_libio_lock();
- if (rtems_libio_iop_freelist) {
- iop = rtems_libio_iop_freelist;
- rtems_libio_iop_freelist = iop->data1;
- memset( iop, 0, sizeof(*iop) );
+ iop = rtems_libio_iop_free_head;
+
+ if ( iop != NULL ) {
+ void *next;
+
+ next = iop->data1;
+ rtems_libio_iop_free_head = next;
+
+ if ( next == NULL ) {
+ rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
+ }
}
rtems_libio_unlock();
@@ -131,9 +138,9 @@ void rtems_libio_free(
rtems_libio_lock();
- iop->flags = 0;
- iop->data1 = rtems_libio_iop_freelist;
- rtems_libio_iop_freelist = iop;
+ iop = memset( iop, 0, sizeof( *iop ) );
+ *rtems_libio_iop_free_tail = iop;
+ rtems_libio_iop_free_tail = &iop->data1;
rtems_libio_unlock();
}