SCSI half mallocs in scsi_malloc
This commit is contained in:
@@ -47,7 +47,6 @@ scsi_free_scsi_task(struct scsi_task *task)
|
|||||||
|
|
||||||
while ((mem = task->mem)) {
|
while ((mem = task->mem)) {
|
||||||
SLIST_REMOVE(&task->mem, mem);
|
SLIST_REMOVE(&task->mem, mem);
|
||||||
free(mem->ptr);
|
|
||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,17 +59,12 @@ scsi_malloc(struct scsi_task *task, size_t size)
|
|||||||
{
|
{
|
||||||
struct scsi_allocated_memory *mem;
|
struct scsi_allocated_memory *mem;
|
||||||
|
|
||||||
mem = malloc(sizeof(struct scsi_allocated_memory));
|
mem = malloc(sizeof(struct scsi_allocated_memory) + size);
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(mem, 0, sizeof(struct scsi_allocated_memory));
|
memset(mem, 0, sizeof(struct scsi_allocated_memory) + size);
|
||||||
mem->ptr = malloc(size);
|
mem->ptr = (void *) ((uintptr_t)mem + sizeof(struct scsi_allocated_memory));
|
||||||
if (mem->ptr == NULL) {
|
|
||||||
free(mem);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memset(mem->ptr, 0, size);
|
|
||||||
SLIST_ADD(&task->mem, mem);
|
SLIST_ADD(&task->mem, mem);
|
||||||
return mem->ptr;
|
return mem->ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user