Lely core libraries  2.3.4
handle.c File Reference
#include "io.h"
#include <lely/util/errnum.h>
#include <assert.h>
#include <stdlib.h>
#include "handle.h"
Include dependency graph for handle.c:

Go to the source code of this file.

Functions

io_handle_t io_handle_acquire (io_handle_t handle)
 Increments the reference count of an I/O device handle. More...
 
void io_handle_release (io_handle_t handle)
 Decrements the reference count of an I/O device handle. More...
 
int io_handle_unique (io_handle_t handle)
 Returns 1 if there is only a single reference to the specified I/O device handle, and 0 otherwise.
 
struct io_handleio_handle_alloc (const struct io_handle_vtab *vtab)
 Allocates a new I/O device handle from a virtual table. More...
 
void io_handle_fini (struct io_handle *handle)
 Finalizes an I/O device handle by invoking its fini method, if available.
 
void io_handle_free (struct io_handle *handle)
 Frees an I/O device handle. More...
 
void io_handle_destroy (struct io_handle *handle)
 Destroys an I/O device handle. More...
 
void io_handle_lock (struct io_handle *handle)
 Locks an unlocked I/O device handle, so the flags (and other device-specific fields) can safely be accessed. More...
 
void io_handle_unlock (struct io_handle *handle)
 Unlocks a locked I/O device handle. More...
 

Detailed Description

This file is part of the I/O library; it contains the implementation of the I/O handle functions.

See also
src/handle.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file handle.c.

Function Documentation

◆ io_handle_acquire()

io_handle_t io_handle_acquire ( io_handle_t  handle)

Increments the reference count of an I/O device handle.

Returns
handle.
See also
io_handle_release()

Definition at line 36 of file handle.c.

◆ io_handle_release()

void io_handle_release ( io_handle_t  handle)

Decrements the reference count of an I/O device handle.

If the count reaches zero, the handle is destroyed.

See also
io_handle_acquire()

Definition at line 51 of file handle.c.

◆ io_handle_alloc()

struct io_handle* io_handle_alloc ( const struct io_handle_vtab vtab)

Allocates a new I/O device handle from a virtual table.

On success, the reference count is initialized to zero.

Returns
a pointer to a new device handle, or NULL on error.
See also
io_handle_free().

Definition at line 81 of file handle.c.

◆ io_handle_free()

void io_handle_free ( struct io_handle handle)

Frees an I/O device handle.

See also
io_handle_alloc()

Definition at line 120 of file handle.c.

◆ io_handle_destroy()

void io_handle_destroy ( struct io_handle handle)

Destroys an I/O device handle.

This function SHOULD never be called directly. Call io_handle_release() instead.

Definition at line 132 of file handle.c.

◆ io_handle_lock()

void io_handle_lock ( struct io_handle handle)

Locks an unlocked I/O device handle, so the flags (and other device-specific fields) can safely be accessed.

See also
io_handle_unlock()

Definition at line 143 of file handle.c.

◆ io_handle_unlock()

void io_handle_unlock ( struct io_handle handle)

Unlocks a locked I/O device handle.

See also
io_handle_lock()

Definition at line 151 of file handle.c.