* Cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31008 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-06-11 08:48:40 +00:00
parent 09173f8089
commit f8daaadc80
+30 -33
View File
@@ -125,8 +125,8 @@ struct data_node {
struct net_buffer_private : net_buffer {
struct list buffers;
data_header *allocation_header; // the current place where we
// allocate header space (nodes,...)
data_header* allocation_header;
// the current place where we allocate header space (nodes, ...)
ancillary_data_container* ancillary_data;
struct {
@@ -578,9 +578,11 @@ dump_buffer(net_buffer *_buffer)
dprintf("buffer %p, size %ld\n", buffer, buffer->size);
data_node* node = NULL;
while ((node = (data_node *)list_get_next_item(&buffer->buffers, node)) != NULL) {
dprintf(" node %p, offset %lu, used %u, header %u, tail %u, header %p\n",
node, node->offset, node->used, node->HeaderSpace(), node->TailSpace(), node->header);
while ((node = (data_node*)list_get_next_item(&buffer->buffers, node))
!= NULL) {
dprintf(" node %p, offset %lu, used %u, header %u, tail %u, "
"header %p\n", node, node->offset, node->used, node->HeaderSpace(),
node->TailSpace(), node->header);
//dump_block((char*)node->start, node->used, " ");
dump_block((char*)node->start, min_c(node->used, 32), " ");
}
@@ -789,8 +791,7 @@ free_data_header_space(data_header *header, uint8 *data, size_t size)
}
/*!
Tries to allocate \a size bytes from the free space in the header.
/*! Tries to allocate \a size bytes from the free space in the header.
*/
static uint8*
alloc_data_header_space(data_header* header, size_t size)
@@ -801,11 +802,12 @@ alloc_data_header_space(data_header *header, size_t size)
if (header->first_free != NULL && header->first_free->size >= size) {
// the first entry of the header space matches the allocation's needs
// TODO: If the free space is greater than what shall be allocated, we leak
// the remainder of the space. We should only allocate multiples of
// _ALIGN(sizeof(free_data)) and split free space in this case. It's not that
// pressing, since the only thing allocated ATM are data_nodes, and thus the
// free space entries will always have the right size.
// TODO: If the free space is greater than what shall be allocated, we
// leak the remainder of the space. We should only allocate multiples of
// _ALIGN(sizeof(free_data)) and split free space in this case. It's not
// that pressing, since the only thing allocated ATM are data_nodes, and
// thus the free space entries will always have the right size.
uint8* data = (uint8*)header->first_free;
header->first_free = header->first_free->next;
return data;
@@ -1086,8 +1088,8 @@ free_buffer(net_buffer *_buffer)
CHECK_BUFFER(buffer);
DELETE_PARANOIA_CHECK_SET(buffer);
data_node *node;
while ((node = (data_node *)list_remove_head_item(&buffer->buffers)) != NULL) {
while (data_node* node
= (data_node*)list_remove_head_item(&buffer->buffers)) {
remove_data_node(node);
}
@@ -1226,7 +1228,8 @@ clone_buffer(net_buffer *_buffer, bool shareFreeSpace)
// add node to clone's list of buffers
list_add_item(&clone->buffers, node);
sourceNode = (data_node *)list_get_next_item(&buffer->buffers, sourceNode);
sourceNode = (data_node*)list_get_next_item(&buffer->buffers,
sourceNode);
if (sourceNode == NULL)
break;
@@ -1255,8 +1258,7 @@ clone_buffer(net_buffer *_buffer, bool shareFreeSpace)
}
/*!
Split the buffer at offset, the header data
/*! Split the buffer at offset, the header data
is returned as new buffer.
*/
static net_buffer*
@@ -1289,8 +1291,7 @@ split_buffer(net_buffer *from, uint32 offset)
}
/*!
Merges the second buffer with the first. If \a after is \c true, the
/*! Merges the second buffer with the first. If \a after is \c true, the
second buffer's contents will be appended to the first ones, else they
will be prepended.
The second buffer will be freed if this function succeeds.
@@ -1545,7 +1546,8 @@ prepend_size(net_buffer *_buffer, size_t size, void **_contiguousBuffer)
*_contiguousBuffer = node->start;
// adjust offset of following nodes
while ((node = (data_node *)list_get_next_item(&buffer->buffers, node)) != NULL) {
while ((node = (data_node*)list_get_next_item(&buffer->buffers, node))
!= NULL) {
node->offset += size;
}
}
@@ -1690,8 +1692,7 @@ append_data(net_buffer *buffer, const void *data, size_t size)
}
/*!
Removes bytes from the beginning of the buffer.
/*! Removes bytes from the beginning of the buffer.
*/
static status_t
remove_header(net_buffer* _buffer, size_t bytes)
@@ -1761,8 +1762,7 @@ remove_header(net_buffer *_buffer, size_t bytes)
}
/*!
Removes bytes from the end of the buffer.
/*! Removes bytes from the end of the buffer.
*/
static status_t
remove_trailer(net_buffer* buffer, size_t bytes)
@@ -1771,8 +1771,7 @@ remove_trailer(net_buffer *buffer, size_t bytes)
}
/*!
Trims the buffer to the specified \a newSize by removing space from
/*! Trims the buffer to the specified \a newSize by removing space from
the end of the buffer.
*/
static status_t
@@ -1824,8 +1823,7 @@ trim_data(net_buffer *_buffer, size_t newSize)
}
/*!
Appends data coming from buffer \a source to the buffer \a buffer. It only
/*! Appends data coming from buffer \a source to the buffer \a buffer. It only
clones the data, though, that is the data is not copied, just referenced.
*/
static status_t
@@ -1908,8 +1906,7 @@ get_ancillary_data(net_buffer *buffer)
}
/*!
Moves all ancillary data from buffer \c from to the end of the list of
/*! Moves all ancillary data from buffer \c from to the end of the list of
ancillary data of buffer \c to. Note, that this is the only function that
transfers or copies ancillary data from one buffer to another.
@@ -1947,8 +1944,7 @@ transfer_ancillary_data(net_buffer *_from, net_buffer *_to)
}
/*!
Tries to directly access the requested space in the buffer.
/*! Tries to directly access the requested space in the buffer.
If the space is contiguous, the function will succeed and place a pointer
to that space into \a _contiguousBuffer.
@@ -1963,7 +1959,8 @@ direct_access(net_buffer *_buffer, uint32 offset, size_t size,
ParanoiaChecker _(buffer);
//TRACE(("direct_access(buffer %p, offset %ld, size %ld)\n", buffer, offset, size));
//TRACE(("direct_access(buffer %p, offset %ld, size %ld)\n", buffer, offset,
// size));
if (offset + size > buffer->size)
return B_BAD_VALUE;