Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

iovec.h File Reference

#include "common.h"

Go to the source code of this file.

Functions

iovec * iov_alloc_n (size_t n)
 Allocates an array of "struct iov" elements.
iovec iov_get (gpointer base, size_t size)
void iov_reset_n (struct iovec *iov, size_t n)
 Resets an array of "struct iov" elements, so that iov_base is NULL and iov_len is 0 for each element.
size_t iov_init_from_string_vector (struct iovec *iov, size_t iov_cnt, gchar *argv[], size_t argc)
 Initializes the elements of an struct iovec array from an array of strings.
gboolean iov_is_contiguous (const struct iovec *const a, const struct iovec *const b)
 Checks whether two given struct iovec point to contiguous memory.
size_t iov_contiguous_size (const struct iovec *iov, size_t iov_cnt)
 Returns the size of contiguous memory buffers.
void iov_clear (struct iovec *iov, size_t byte_offset)
 Clear all bytes in the buffer starting at the given offset.
size_t iov_calculate_size (struct iovec *iov, size_t iov_cnt)
 Calculates the cumulative size of the memory buffers.
size_t iov_scatter_string (struct iovec *iov, size_t iov_cnt, const gchar *s)
 Scatters a NUL-terminated string over an array of struct iovec buffers.


Function Documentation

struct iovec* iov_alloc_n size_t  n  )  [inline, static]
 

Allocates an array of "struct iov" elements.

Parameters:
n The desired array length in elements.

size_t iov_calculate_size struct iovec *  iov,
size_t  iov_cnt
[inline, static]
 

Calculates the cumulative size of the memory buffers.

This uses saturation arithmetic, so the returned value can never overflow.

Parameters:
iov An array of initialized memory buffers.
iov_cnt The array length of iov.
Returns:
The sum of all buffer sizes.

void iov_clear struct iovec *  iov,
size_t  byte_offset
[inline, static]
 

Clear all bytes in the buffer starting at the given offset.

If the offset is beyond iov->iov_len, nothing happens.

Parameters:
iov An initialized struct iovec.
byte_offset The offset relative to iov->iov_base.

size_t iov_contiguous_size const struct iovec *  iov,
size_t  iov_cnt
[inline, static]
 

Returns the size of contiguous memory buffers.

Parameters:
iov An array of initialized memory buffers.
iov_cnt The array length of iov.
Returns:
The amount contiguous bytes.

struct iovec iov_get gpointer  base,
size_t  size
[inline, static]
 

size_t iov_init_from_string_vector struct iovec *  iov,
size_t  iov_cnt,
gchar *  argv[],
size_t  argc
[inline, static]
 

Initializes the elements of an struct iovec array from an array of strings.

iov_len is set to string length plus one to include the trailing NUL.

Parameters:
iov An array of writable initialized memory buffers.
iov_cnt The array length of iov.
src The source buffer to copy.
size The amount of bytes to copy from "src".
Returns:
The amount of elements initialized. Thus, MIN(iov_cnt, argc).

gboolean iov_is_contiguous const struct iovec *const   a,
const struct iovec *const   b
[inline, static]
 

Checks whether two given struct iovec point to contiguous memory.

Returns:
TRUE if b->iov_base directly follows after &a->iov_base[a->iov_len].

void iov_reset_n struct iovec *  iov,
size_t  n
[inline, static]
 

Resets an array of "struct iov" elements, so that iov_base is NULL and iov_len is 0 for each element.

Parameters:
iov The array base.
n The array length in elements.

size_t iov_scatter_string struct iovec *  iov,
size_t  iov_cnt,
const gchar *  s
[inline, static]
 

Scatters a NUL-terminated string over an array of struct iovec buffers.

The trailing buffer space is zero-filled. If the string is too long, it is truncated, so that there is a terminating NUL in any case, except if the buffer space is zero.

Parameters:
iov An array of initialized memory buffers.
iov_cnt The array length of iov.
Returns:
The amount of bytes copied excluding the terminating NUL.


Generated on Sat Jun 30 17:53:28 2007 for gtk-gnutella by  doxygen 1.3.9.1