safelock.c
/* Free a safelock_t object and its resources */
Free a safelock_t object and its resources
Free a safelock_t object and its resources
int safelock_close(safelock_t *lock)
{
    lock_data_t *shared;
    int err;
    assert(lock && *lock);
    shared = (*lock)->shared;
    err = 0;
    if ((*lock)->locked)
        err = safelock_unlock(*lock);
    if (err == EINVAL)
        err = 0;
    munmap_lock_data(shared);
    close((*lock)->fd);
    free((*lock)->filename);
    free(*lock);
    *lock = NULL;
    return err;
}
int safelock_close ( safelock_t * lock ) { lock_data_t * shared ; int err ; assert ( lock && * lock ) ; shared = ( * lock ) -> shared ; err = 0 ; if ( ( * lock ) -> locked ) err = safelock_unlock ( * lock ) ; if ( err == EINVAL ) err = 0 ; munmap_lock_data ( shared ) ; close ( ( * lock ) -> fd ) ; free ( ( * lock ) -> filename ) ; free ( * lock ) ; * lock = NULL ; return err ; }
Free a safelock_t object and its resources
Free a safelock_t object and its resources
/* Don't unlink() since a new locker may be pending.
     * Allow applications to make that policy decision by using
     * safelock_remove() before calling safelock_close(). */ /* Skip returning EINVAL since the caller will have to
     * re-open the lock anyway.. */ /* Skip handling close() errors. The file descriptor state is
     * undefined after an error, but is likely closed. Worst case,
     * the file descriptor may be leaked. */