blender/intern/ghost/test/multitest/Util.c
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

49 lines
867 B
C

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "Util.h"
void *memdbl(void *mem, int *size_pr, int item_size)
{
int cur_size = *size_pr;
int new_size = cur_size ? (cur_size * 2) : 1;
void *nmem = MEM_mallocN(new_size * item_size, "memdbl");
memcpy(nmem, mem, cur_size * item_size);
MEM_freeN(mem);
*size_pr = new_size;
return nmem;
}
char *string_dup(char *str)
{
int len = strlen(str);
char *nstr = MEM_mallocN(len + 1, "string_dup");
memcpy(nstr, str, len + 1);
return nstr;
}
void fatal(char *fmt, ...)
{
va_list ap;
fprintf(stderr, "FATAL: ");
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(1);
}