src/buffer_util.h File Reference

Utility function used by bless_buffer_t. More...

#include <sys/types.h>
#include "buffer.h"
#include "buffer_action.h"
#include "segcol.h"
#include "segment.h"
#include "data_object.h"
#include "list.h"
Include dependency graph for buffer_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int read_data_object (data_object_t *dobj, off_t offset, void *mem, off_t length)
 Reads data from a data object to memory.
int write_data_object (data_object_t *dobj, off_t offset, off_t length, int fd, off_t file_offset)
 Writes data from a data object to a file.
int write_data_object_safe (data_object_t *dobj, off_t offset, off_t length, int fd, off_t file_offset)
 Writes data from a data object to a file in a safe way.
int segcol_foreach (segcol_t *segcol, off_t offset, off_t length, segcol_foreach_func *func, void *user_data)
 Calls a function for each segment in the specified range of a segcol_t.
int segcol_store_in_memory (segcol_t *segcol, off_t offset, off_t length)
 Stores a range from a segcol_t in memory data objects.
int segcol_store_in_file (segcol_t *segcol, off_t offset, off_t length, char *tmpdir)
 Stores a range from a segcol_t in a file data object.
int segcol_add_copy (segcol_t *dst, off_t offset, segcol_t *src)
 Copies data from a segcol into another.
int undo_list_enforce_limit (bless_buffer_t *buf, int ensure_vacancy)
 Enforces the undo limit on the undo list.
int action_list_clear (list_t *action_list)
 Clears an action list's contents without freeing the list itself.
int undo_list_append (bless_buffer_t *buf, buffer_action_t *action)
 Appends a buffer_action_t to the undo list of a buffer.

Detailed Description

Utility function used by bless_buffer_t.

Definition in file buffer_util.h.


Function Documentation

int action_list_clear ( list_t action_list  ) 

Clears an action list's contents without freeing the list itself.

Parameters:
action_list the action_list
Returns:
the operation error code

Definition at line 767 of file buffer_util.c.

References buffer_action_free(), list_delete_chain(), list_entry, list_for_each_safe, and list_head().

Referenced by bless_buffer_append(), bless_buffer_begin_multi_action(), bless_buffer_delete(), bless_buffer_insert(), bless_buffer_save(), and bless_buffer_set_option().

Here is the call graph for this function:

Here is the caller graph for this function:

int read_data_object ( data_object_t dobj,
off_t  offset,
void *  mem,
off_t  length 
)

Reads data from a data object to memory.

Parameters:
dobj the data object to read from
offset the offset in the data object to read from
mem the memory to save the data to
length the number of bytes to read
Returns:
the operation error code

Definition at line 57 of file buffer_util.c.

References data_object_get_data(), and DATA_OBJECT_READ.

Referenced by read_foreach_func(), read_segment_func(), and write_data_object_safe().

Here is the call graph for this function:

Here is the caller graph for this function:

int segcol_add_copy ( segcol_t dst,
off_t  offset,
segcol_t src 
)

Copies data from a segcol into another.

The dst and src segcol must not be the same.

Parameters:
dst the segcol to copy data into
offset the offset in the segcol to copy data into
src the segcol to copy data from
Returns:
the operation error code

Definition at line 630 of file buffer_util.c.

References segcol_append(), segcol_delete(), segcol_get_size(), segcol_insert(), segcol_iter_free(), segcol_iter_get_mapping(), segcol_iter_get_segment(), segcol_iter_is_valid(), segcol_iter_new(), segcol_iter_next(), segment_copy(), and segment_free().

Here is the call graph for this function:

int segcol_foreach ( segcol_t segcol,
off_t  offset,
off_t  length,
segcol_foreach_func *  func,
void *  user_data 
)

Calls a function for each segment in the specified range of a segcol_t.

Parameters:
segcol the segcol_t to search in
offset the offset in the segcol_t to start from
length the length of the range
func the function to call for each segment
user_data user specified data to pass to func
Returns:
the operation error code

Definition at line 296 of file buffer_util.c.

References get_data_from_iter(), segcol_find(), segcol_get_size(), segcol_iter_free(), segcol_iter_is_valid(), and segcol_iter_next().

Referenced by bless_buffer_read(), segcol_store_in_file(), and segcol_store_in_memory().

Here is the call graph for this function:

Here is the caller graph for this function:

int segcol_store_in_file ( segcol_t segcol,
off_t  offset,
off_t  length,
char *  tmpdir 
)

Stores a range from a segcol_t in a file data object.

Parameters:
segcol the segcol_t
offset the offset to starting storing from
length the length of the data to store
tmpdir the directory where to create the file
Returns:
the operation error code

Definition at line 527 of file buffer_util.c.

References data_object_file_set_close_func(), data_object_free(), data_object_tempfile_new(), data_object_update_usage(), path_join(), segcol_append(), segcol_delete(), segcol_foreach(), segcol_get_size(), segcol_insert(), segment_free(), segment_new(), and store_segment_func().

Referenced by break_edge().

Here is the call graph for this function:

Here is the caller graph for this function:

int segcol_store_in_memory ( segcol_t segcol,
off_t  offset,
off_t  length 
)

Stores a range from a segcol_t in memory data objects.

Parameters:
segcol the segcol_t
offset the offset to starting storing from
length the length of the data to store
Returns:
the operation error code

Definition at line 415 of file buffer_util.c.

References data_object_free(), data_object_memory_new(), data_object_memory_set_free_func(), data_object_update_usage(), read_segment_func(), segcol_append(), segcol_delete(), segcol_foreach(), segcol_get_size(), segcol_insert(), segment_free(), and segment_new().

Referenced by break_edge().

Here is the call graph for this function:

Here is the caller graph for this function:

int undo_list_append ( bless_buffer_t buf,
buffer_action_t action 
)

Appends a buffer_action_t to the undo list of a buffer.

Parameters:
buf the bless_buffer_t to append to
action the action to append
Returns:
the operation error code

Definition at line 799 of file buffer_util.c.

References list_insert_before(), and list_tail().

Referenced by bless_buffer_append(), bless_buffer_begin_multi_action(), bless_buffer_delete(), and bless_buffer_insert().

Here is the call graph for this function:

Here is the caller graph for this function:

int undo_list_enforce_limit ( bless_buffer_t buf,
int  ensure_vacancy 
)

Enforces the undo limit on the undo list.

After the operation the undo list contains at most the most recent buf->options->undo_limit actions. Additionally if ensure_vacancy == 1 the undo list contains space for at least one action (unless the undo limit is 0).

Parameters:
buf the bless_buffer_t
ensure_vacancy whether to make sure that there is space for one additional action
Returns:
the operation error code

Definition at line 713 of file buffer_util.c.

References buffer_action_free(), list_delete_chain(), list_entry, list_for_each_safe, and list_head().

Referenced by bless_buffer_append(), bless_buffer_begin_multi_action(), bless_buffer_delete(), bless_buffer_insert(), and bless_buffer_set_option().

Here is the call graph for this function:

Here is the caller graph for this function:

int write_data_object ( data_object_t dobj,
off_t  offset,
off_t  length,
int  fd,
off_t  file_offset 
)

Writes data from a data object to a file.

Use write_data_object_safe() instead of this function when writing to the same file that the data object is associated with and there is an overlap between the original data object range and the range we are writing it to.

Parameters:
dobj the data object to read from
offset the offset in the data object to read from
length the number of bytes to read
fd the file descriptor to write the data to
file_offset the offset in the file to write the data
Returns:
the operation error code

Definition at line 109 of file buffer_util.c.

References data_object_get_data(), and DATA_OBJECT_READ.

Referenced by store_segment_func(), and write_segment().

Here is the call graph for this function:

Here is the caller graph for this function:

int write_data_object_safe ( data_object_t dobj,
off_t  offset,
off_t  length,
int  fd,
off_t  file_offset 
)

Writes data from a data object to a file in a safe way.

Use this function instead of write_data_object() when writing to the same file that the data object is associated with and there is an overlap between the original data object range and the range we are writing it to.

Parameters:
dobj the data object to read from
offset the offset in the data object to read from
length the number of bytes to read
fd the file descriptor to write the data to
file_offset the offset in the file to write the data
Returns:
the operation error code

Definition at line 157 of file buffer_util.c.

References read_data_object().

Referenced by write_segment().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Nov 15 15:27:45 2009 for libbls by  doxygen 1.6.1