blob: 382195eb9a26619c40a8da718cd5820d569c4d41 [file] [log] [blame]
Chisato Kenmochi94704432017-01-10 11:56:48 +09001/*
2 * Copyright (C) 2003 - 2016 Sony Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "ldac.h"
18
19/***************************************************************************************************
20 Align Memory
21***************************************************************************************************/
22#define LDAC_ALLOC_LINE 8
23
24DECLFUNC size_t align_ldac(
25size_t size)
26{
27 if (LDAC_ALLOC_LINE != 0) {
28 size = (((size-1)/LDAC_ALLOC_LINE)+1) * LDAC_ALLOC_LINE;
29 }
30
31 return size;
32}
33
34/***************************************************************************************************
35 Clear Allocate Memory
36***************************************************************************************************/
37DECLFUNC void *calloc_ldac(
38SFINFO *p_sfinfo,
39size_t nmemb,
40size_t size)
41{
42 char *p_tmp;
43
44 if (p_sfinfo->p_mempos != (char *)NULL) {
45 p_tmp = p_sfinfo->p_mempos;
46 p_sfinfo->p_mempos += nmemb * align_ldac(size);
47 }
48 else {
49 p_tmp = calloc(nmemb, size);
50 }
51
52 return (void *)p_tmp;
53}
54