Commit 6ac5602e authored by Greg Williams's avatar Greg Williams
Browse files

Removed kinetic_serial_allocator, since it was refactored out and has issues...

Removed kinetic_serial_allocator, since it was refactored out and has issues in 32-bit client lib builds.
parent a99c453a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ LIB_OBJS = \
	$(OUT_DIR)/kinetic_hmac.o \
	$(OUT_DIR)/kinetic_controller.o \
	$(OUT_DIR)/kinetic_device_info.o \
	$(OUT_DIR)/kinetic_serial_allocator.o \
	$(OUT_DIR)/kinetic_session.o \
	$(OUT_DIR)/kinetic_types_internal.o \
	$(OUT_DIR)/kinetic_types.o \
+0 −76
Original line number Diff line number Diff line
/*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "kinetic_serial_allocator.h"
#include "kinetic_logger.h"
#include <stdlib.h>
#include <sys/param.h>

KineticSerialAllocator KineticSerialAllocator_Create(size_t max_len) {
    return (KineticSerialAllocator) {
        .buffer = calloc(1, max_len),
        .total = max_len,
        .used = 0,
    };
}

void* KineticSerialAllocator_GetBuffer(KineticSerialAllocator* allocator)
{
    KINETIC_ASSERT(allocator != NULL);
    return allocator->buffer;
}

void* KineticSerialAllocator_AllocateChunk(KineticSerialAllocator* allocator, size_t len)
{
    void* data = NULL;
    
    if (allocator->buffer != NULL ||
        ((unsigned long long)allocator->buffer) % sizeof(uint64_t) == 0 || // Ensure root of buffer is long-aligned
        allocator->used < allocator->total)
    {
        // Align to the next allocated hunk of data to the next 64-bit boundary
        size_t newUsed = allocator->used + len;

        // Assign pointer to new hunk of data
        if (newUsed <= allocator->total) {
            data = (void*)&allocator->buffer[allocator->used];
        }

        // Mark buffer full, if the current allocation has exhausted allocated data
        const size_t padding = (sizeof(uint64_t) - 1);
        newUsed += padding;
        newUsed &= ~padding;
        allocator->used = MIN(newUsed, allocator->total);
    }

    return data;
}

size_t KineticSerialAllocator_TrimBuffer(KineticSerialAllocator* allocator)
{
    KINETIC_ASSERT(allocator != NULL);
    KINETIC_ASSERT(allocator->buffer != NULL);
    void* final = realloc(allocator->buffer, allocator->used);
    KINETIC_ASSERT(final != NULL);
    allocator->buffer = final;
    allocator->total = allocator->used;
    printf("allocator->buffer, post-trim: %p\n", (void *)allocator->buffer);
    return allocator->total;
}
+0 −31
Original line number Diff line number Diff line
/*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef _KINETIC_SERIAL_ALLOCATOR_H
#define _KINETIC_SERIAL_ALLOCATOR_H

#include "kinetic_types_internal.h"

KineticSerialAllocator KineticSerialAllocator_Create(size_t max_len);
void* KineticSerialAllocator_GetBuffer(KineticSerialAllocator* allocator);
void* KineticSerialAllocator_AllocateChunk(KineticSerialAllocator* allocator, size_t len);
size_t KineticSerialAllocator_TrimBuffer(KineticSerialAllocator* allocator);

#endif // _KINETIC_SERIAL_ALLOCATOR_H
+0 −8
Original line number Diff line number Diff line
@@ -181,14 +181,6 @@ struct _KineticOperation {
    KineticCompletionClosure closure;
};

// Kintic Serial Allocator
// Used for allocating a contiguous hunk of memory to hold arbitrary variable-length response data
typedef struct _KineticSerialAllocator {
    uint8_t* buffer;
    size_t used;
    size_t total;
} KineticSerialAllocator;


KineticProto_Command_Algorithm KineticProto_Command_Algorithm_from_KineticAlgorithm(
    KineticAlgorithm kinteicAlgorithm);
+0 −1
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
#include "kinetic_types_internal.h"
#include "kinetic_controller.h"
#include "kinetic_device_info.h"
#include "kinetic_serial_allocator.h"
#include "kinetic_proto.h"
#include "kinetic_allocator.h"
#include "kinetic_message.h"
Loading