Segment

A segment holds information about a continuous part of a data object. More...

Typedefs

typedef struct segment segment_t
 Opaque type for segment ADT.
typedef int(* segment_data_usage_func )(void *data, int change)
 Function called to change the usage count of some data.

Functions

int segment_new (segment_t **seg, void *data, off_t start, off_t size, segment_data_usage_func data_usage_func)
 Creates a new segment_t.
int segment_copy (segment_t *seg, segment_t **seg_copy)
 Creates a copy of a segment_t.
int segment_free (segment_t *seg)
 Frees a segment_t.
int segment_clear (segment_t *seg)
 Clears a segment_t.
int segment_split (segment_t *seg, segment_t **seg1, off_t split_index)
 Splits a segment.
int segment_merge (segment_t *seg, segment_t *seg1)
 Merges two segments.
int segment_get_data (segment_t *seg, void **data)
 Gets data object a segment_t is related to.
int segment_get_start (segment_t *seg, off_t *start)
 Gets the start offset of a segment_t.
int segment_get_size (segment_t *seg, off_t *size)
 Gets the size of a segment_t.
int segment_set_data (segment_t *seg, void *data, segment_data_usage_func data_usage_func)
 Sets the data association of a segment_t.
int segment_set_range (segment_t *seg, off_t start, off_t size)
 Sets the range of a segment_t.

Detailed Description

A segment holds information about a continuous part of a data object.

By default, when a segment becomes associated with a data object, the segment is not responsible for managing the data object's memory. This kind of memory management can be achieved be specifying the data_usage_func when creating the segment or changing its data association. The function is called whenever the segment is created or freed and updates the data object's usage count.


Typedef Documentation

typedef int(* segment_data_usage_func)(void *data, int change)

Function called to change the usage count of some data.

Parameters:
data the data whose usage count is being changed
change the change in the usage count or 0 to reset the count
Returns:
the operation error code

Definition at line 58 of file segment.h.


Function Documentation

int segment_clear ( segment_t seg  ) 

Clears a segment_t.

Parameters:
seg the segment_t to clear
Returns:
the operation error code

Definition at line 127 of file segment.c.

Referenced by segment_split().

Here is the caller graph for this function:

int segment_copy ( segment_t seg,
segment_t **  seg_copy 
)

Creates a copy of a segment_t.

Parameters:
seg the segment_t to copy
[out] seg_copy the new copy of the segment
Returns:
the operation error code

Definition at line 88 of file segment.c.

References segment_new().

Referenced by overlap_graph_add_segment(), and segcol_add_copy().

Here is the call graph for this function:

Here is the caller graph for this function:

int segment_free ( segment_t seg  ) 

Frees a segment_t.

Parameters:
seg the segment_t to free
Returns:
the operation error code

Definition at line 109 of file segment.c.

Referenced by bless_buffer_save(), overlap_graph_add_segment(), overlap_graph_free(), segcol_add_copy(), segcol_store_in_file(), segcol_store_in_memory(), and segment_split().

Here is the caller graph for this function:

int segment_get_data ( segment_t seg,
void **  data 
)

Gets data object a segment_t is related to.

Parameters:
seg the segment_t
[out] data the data object
Returns:
the operation error code

Definition at line 241 of file segment.c.

Referenced by break_edge(), create_overlap_graph(), read_foreach_func(), read_segment_func(), store_segment_func(), write_segcol_rest(), and write_segment().

Here is the caller graph for this function:

int segment_get_size ( segment_t seg,
off_t *  size 
)

Gets the size of a segment_t.

Parameters:
seg the segment_t
[out] size the size
Returns:
the operation error code

Definition at line 277 of file segment.c.

Referenced by get_data_from_iter(), overlap_graph_add_segment(), segcol_append(), segcol_insert(), and write_segment().

Here is the caller graph for this function:

int segment_get_start ( segment_t seg,
off_t *  start 
)

Gets the start offset of a segment_t.

Parameters:
seg the segment_t
[out] start the start offset
Returns:
the operation error code

Definition at line 259 of file segment.c.

Referenced by break_edge(), get_data_from_iter(), overlap_graph_add_segment(), and write_segment().

Here is the caller graph for this function:

int segment_merge ( segment_t seg,
segment_t seg1 
)

Merges two segments.

This function merges two related segments. Segment seg1 must be a continuation of the first segment for the merge to succeed. The first segment is changed in place.

Parameters:
seg the first segment
seg1 the segment to merge with the first segment
Returns:

Definition at line 205 of file segment.c.

int segment_new ( segment_t **  seg,
void *  data,
off_t  start,
off_t  size,
segment_data_usage_func  data_usage_func 
)

Creates a new segment_t.

Parameters:
[out] seg the created segment or NULL
data the data object this segment is associated with
start the start offset of the segment
size the size of the segment
data_usage_func the function to call to update the usage count of the data associated with this segment (may be NULL)
Returns:
the operation error code

Definition at line 50 of file segment.c.

References segment_set_data(), and segment_set_range().

Referenced by bless_buffer_save(), segcol_store_in_file(), segcol_store_in_memory(), segment_copy(), and segment_split().

Here is the call graph for this function:

Here is the caller graph for this function:

int segment_set_data ( segment_t seg,
void *  data,
segment_data_usage_func  data_usage_func 
)

Sets the data association of a segment_t.

Parameters:
seg the segment_t
data the new data associated with the segment
data_usage_func the function to call to update the usage count of the data associated with this segment (may be NULL)
Returns:
the operation error code

Definition at line 297 of file segment.c.

Referenced by segment_new().

Here is the caller graph for this function:

int segment_set_range ( segment_t seg,
off_t  start,
off_t  size 
)

Sets the range of a segment_t.

Parameters:
seg the segment_t
start the new start offset
size the size of the segment
Returns:
the operation error code

Definition at line 335 of file segment.c.

Referenced by segment_new(), and segment_split().

Here is the caller graph for this function:

int segment_split ( segment_t seg,
segment_t **  seg1,
off_t  split_index 
)

Splits a segment.

This functions splits a segment into two. The original segment is changed in-place and a new one is created. The caller is responsible for managing the new segment (eg freeing it).

Parameters:
seg the segment_t to split
[out] seg1 the created new segment
split_index the index in the original segment_t that will be the start of the new segment_t
Returns:
the operation error code

Definition at line 152 of file segment.c.

References segment_clear(), segment_free(), segment_new(), and segment_set_range().

Here is the call graph for this function:


Generated on Sun Nov 15 15:28:01 2009 for libbls by  doxygen 1.6.1