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.   | |
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 int(* segment_data_usage_func)(void *data, int change) | 
| int segment_clear | ( | segment_t * | seg | ) | 
Clears a segment_t.
| seg | the segment_t to clear | 
Definition at line 127 of file segment.c.
Referenced by segment_split().

Creates a copy of a segment_t.
| seg | the segment_t to copy | |
| [out] | seg_copy | the new copy of the segment | 
Definition at line 88 of file segment.c.
References segment_new().
Referenced by overlap_graph_add_segment(), and segcol_add_copy().


| int segment_free | ( | segment_t * | seg | ) | 
Frees a segment_t.
| seg | the segment_t to free | 
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().

| int segment_get_data | ( | segment_t * | seg, | |
| void ** | data | |||
| ) | 
Gets data object a segment_t is related to.
| seg | the segment_t | |
| [out] | data | the data object | 
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().

| int segment_get_size | ( | segment_t * | seg, | |
| off_t * | size | |||
| ) | 
Gets the size of a segment_t.
| seg | the segment_t | |
| [out] | size | the size | 
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().

| int segment_get_start | ( | segment_t * | seg, | |
| off_t * | start | |||
| ) | 
Gets the start offset of a segment_t.
| seg | the segment_t | |
| [out] | start | the start offset | 
Definition at line 259 of file segment.c.
Referenced by break_edge(), get_data_from_iter(), overlap_graph_add_segment(), and write_segment().

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.
| seg | the first segment | |
| seg1 | the segment to merge with the first segment | 
| 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.
| [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) | 
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().


| int segment_set_data | ( | segment_t * | seg, | |
| void * | data, | |||
| segment_data_usage_func | data_usage_func | |||
| ) | 
Sets the data association of a segment_t.
| 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) | 
Definition at line 297 of file segment.c.
Referenced by segment_new().

| int segment_set_range | ( | segment_t * | seg, | |
| off_t | start, | |||
| off_t | size | |||
| ) | 
Sets the range of a segment_t.
| seg | the segment_t | |
| start | the new start offset | |
| size | the size of the segment | 
Definition at line 335 of file segment.c.
Referenced by segment_new(), and segment_split().

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).
| 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 | 
Definition at line 152 of file segment.c.
References segment_clear(), segment_free(), segment_new(), and segment_set_range().

 1.6.1