• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
align_ldac(size_t size)24 DECLFUNC size_t align_ldac(
25 size_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 ***************************************************************************************************/
calloc_ldac(SFINFO * p_sfinfo,size_t nmemb,size_t size)37 DECLFUNC void *calloc_ldac(
38 SFINFO *p_sfinfo,
39 size_t nmemb,
40 size_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 
55