/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#include "mem.h"

void * memBufferResize(void *oldBuffer, int32_t oldSize, int32_t newSize, 
  size_t size
) {
  // Malloc a new buffer
  void *newBuffer = malloc(size * newSize);

  // Copy old data
  memcpy(newBuffer, oldBuffer, size * oldSize);

  // Clear old buffer
  free(oldBuffer);

  return newBuffer;
}