memory: move into subdir
This commit is contained in:
parent
0d9c816fc3
commit
bf7964926c
6 changed files with 31 additions and 14 deletions
|
@ -9,6 +9,8 @@
|
|||
#include "taisei.h"
|
||||
|
||||
#include "memory.h"
|
||||
#include "util.h"
|
||||
#include "../util.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -34,17 +36,6 @@ void mem_free(void *ptr) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static size_t mem_calc_array_size(size_t num_members, size_t size) {
|
||||
size_t array_size;
|
||||
|
||||
if(__builtin_mul_overflow(num_members, size, &array_size)) {
|
||||
assert(0 && "size_t overflow");
|
||||
abort();
|
||||
}
|
||||
|
||||
return array_size;
|
||||
}
|
||||
|
||||
void *mem_alloc(size_t size) {
|
||||
#if MEMALIGN_METHOD == MEMALIGN_METHOD_WIN32
|
||||
void *p = NOT_NULL(_aligned_malloc(size, alignof(max_align_t)));
|
||||
|
@ -110,7 +101,7 @@ void *mem_alloc_aligned(size_t size, size_t alignment) {
|
|||
}
|
||||
|
||||
void *mem_alloc_array_aligned(size_t num_members, size_t size, size_t alignment) {
|
||||
return mem_alloc_aligned(mem_calc_array_size(num_members, size), alignment);
|
||||
return mem_alloc_aligned(mem_util_calc_array_size(num_members, size), alignment);
|
||||
}
|
||||
|
||||
void *mem_dup(const void *src, size_t size) {
|
4
src/memory/meson.build
Normal file
4
src/memory/meson.build
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
memory_src = files(
|
||||
'memory.c',
|
||||
)
|
21
src/memory/util.h
Normal file
21
src/memory/util.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the MIT License.
|
||||
* See COPYING for further information.
|
||||
* ---
|
||||
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
||||
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "taisei.h"
|
||||
|
||||
INLINE size_t mem_util_calc_array_size(size_t num_members, size_t size) {
|
||||
size_t array_size;
|
||||
|
||||
if(__builtin_mul_overflow(num_members, size, &array_size)) {
|
||||
assert(0 && "size_t overflow");
|
||||
abort();
|
||||
}
|
||||
|
||||
return array_size;
|
||||
}
|
|
@ -77,7 +77,6 @@ taisei_src = files(
|
|||
'list.c',
|
||||
'log.c',
|
||||
'main.c',
|
||||
'memory.c',
|
||||
'move.c',
|
||||
'player.c',
|
||||
'plrmodes.c',
|
||||
|
@ -130,6 +129,7 @@ subdir('dialog')
|
|||
subdir('eventloop')
|
||||
subdir('filewatch')
|
||||
subdir('lasers')
|
||||
subdir('memory')
|
||||
subdir('menu')
|
||||
subdir('pixmap')
|
||||
subdir('plrmodes')
|
||||
|
@ -149,6 +149,7 @@ taisei_src += [
|
|||
eventloop_src,
|
||||
filewatch_src,
|
||||
lasers_src,
|
||||
memory_src,
|
||||
menu_src,
|
||||
pixmap_src,
|
||||
plrmodes_src,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "build_config.h"
|
||||
#include "util/compat.h"
|
||||
#include "util/consideredharmful.h"
|
||||
#include "memory.h"
|
||||
#include "memory/memory.h"
|
||||
|
||||
#ifdef TAISEI_BUILDCONF_DEVELOPER
|
||||
// TODO: maybe rename this
|
||||
|
|
Loading…
Reference in a new issue