* net_buffer is a module, so it shouldn't have its initializers called

indirectly by the stack - they are now again usable separately as well.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22673 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-10-23 00:04:41 +00:00
parent 8c5602829e
commit 157da1cd6e
4 changed files with 45 additions and 67 deletions
+37 -50
View File
@@ -309,7 +309,24 @@ get_node_at_offset(net_buffer_private *buffer, size_t offset)
}
// #pragma mark -
static void
copy_metadata(net_buffer *destination, const net_buffer *source)
{
memcpy(destination->source, source->source,
min_c(source->source->sa_len, sizeof(sockaddr_storage)));
memcpy(destination->destination, source->destination,
min_c(source->destination->sa_len, sizeof(sockaddr_storage)));
destination->flags = source->flags;
destination->interface = source->interface;
destination->offset = source->offset;
destination->size = source->size;
destination->protocol = source->protocol;
destination->type = source->type;
}
// #pragma mark - module API
static net_buffer *
@@ -367,23 +384,6 @@ free_buffer(net_buffer *_buffer)
}
static void
copy_metadata(net_buffer *destination, const net_buffer *source)
{
memcpy(destination->source, source->source,
min_c(source->source->sa_len, sizeof(sockaddr_storage)));
memcpy(destination->destination, source->destination,
min_c(source->destination->sa_len, sizeof(sockaddr_storage)));
destination->flags = source->flags;
destination->interface = source->interface;
destination->offset = source->offset;
destination->size = source->size;
destination->protocol = source->protocol;
destination->type = source->type;
}
/*! Creates a duplicate of the \a buffer. The new buffer does not share internal
storage; they are completely independent from each other.
*/
@@ -1185,44 +1185,31 @@ swap_addresses(net_buffer *buffer)
}
status_t
init_net_buffers()
{
// TODO improve our code a bit so we can add constructors
// and keep around half-constructed buffers in the slab
sNetBufferCache = create_object_cache("net buffer cache",
sizeof(net_buffer_private), 8, NULL, NULL, NULL);
if (sNetBufferCache == NULL)
return B_NO_MEMORY;
sDataNodeCache = create_object_cache("data node cache", BUFFER_SIZE, 0,
NULL, NULL, NULL);
if (sDataNodeCache == NULL) {
delete_object_cache(sNetBufferCache);
return B_NO_MEMORY;
}
return B_OK;
}
status_t
uninit_net_buffers()
{
delete_object_cache(sNetBufferCache);
delete_object_cache(sDataNodeCache);
return B_OK;
}
static status_t
std_ops(int32 op, ...)
{
switch (op) {
case B_MODULE_INIT:
// TODO: improve our code a bit so we can add constructors
// and keep around half-constructed buffers in the slab
sNetBufferCache = create_object_cache("net buffer cache",
sizeof(net_buffer_private), 8, NULL, NULL, NULL);
if (sNetBufferCache == NULL)
return B_NO_MEMORY;
sDataNodeCache = create_object_cache("data node cache", BUFFER_SIZE,
0, NULL, NULL, NULL);
if (sDataNodeCache == NULL) {
delete_object_cache(sNetBufferCache);
return B_NO_MEMORY;
}
return B_OK;
case B_MODULE_UNINIT:
delete_object_cache(sNetBufferCache);
delete_object_cache(sDataNodeCache);
return B_OK;
default: