Dawn/src/util/mem.h

26 lines
679 B
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
/**
* Resizes a buffer to hold new amounts of data. Essentially a 3 step process of
* - Malloc (new buffer)
* - Memcpy (from old buffer)
* - Free (old buffer)
* - Return (new buffer)
*
* @param oldBuffer The old buffer.
* @param oldSize The current size of the old buffer.
* @param newSize Size of the new buffer.
* @param size Size of the elements within the buffer.
* @return The new buffer.
*/
void * memBufferResize(void *oldBuffer, int32_t oldSize, int32_t newSize,
size_t size
);