PDU reduce number of mallocs/memcpys in iscsi_add_data()

This patch adds logarithmic malloc behaviour to iscsi_add_data().
Currently for each new call there is a new buffer allocated
and all old data is copied to the new buffer. Change this by
allocating at least PAGE_SIZE bytes and increase the allocation
by powers of 2 each time it does no longer fit.
This commit is contained in:
Peter Lieven
2012-11-03 02:49:56 +01:00
parent d9fbe37f4b
commit c4dc380262
2 changed files with 20 additions and 11 deletions

View File

@@ -33,6 +33,7 @@ struct iscsi_context;
struct sockaddr;
#define MAX_STRING_SIZE (255)
#define PAGE_SIZE (4096)
/*
* Syntax for normal and portal/discovery URLs.
@@ -533,6 +534,7 @@ iscsi_task_mgmt_target_cold_reset_async(struct iscsi_context *iscsi,
struct iscsi_data {
int size;
int alloc_size;
unsigned char *data;
};