Mercurial > hg > Members > koba > t_dandy
comparison sys.c @ 0:435ac1cdb64e
create task dandy directry.
author | koba <koba@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 11 Dec 2010 21:25:28 +0900 |
parents | |
children | b97628fca317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:435ac1cdb64e |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <libxml/parser.h> | |
5 #include "object.h" | |
6 #include "sys.h" | |
7 | |
8 #define ALIGN_16BYTE 16 | |
9 | |
10 int malloc_align16(void *free, void *aligned, int size) | |
11 { | |
12 char *index; | |
13 unsigned int *f=(unsigned int *)free,*a=(unsigned int *)aligned; | |
14 | |
15 if (free == NULL || aligned == NULL || size <= 0) return(-1); | |
16 | |
17 index = (char *)malloc(size + ALIGN_16BYTE); | |
18 if (index == NULL) | |
19 { | |
20 return(-1); | |
21 } | |
22 | |
23 *f = *a = (unsigned int)index; | |
24 if (((unsigned int)index % ALIGN_16BYTE) != 0) | |
25 { | |
26 index += ALIGN_16BYTE - ((unsigned int)index % ALIGN_16BYTE); | |
27 *a = (unsigned int)index; | |
28 } | |
29 return(0); | |
30 } | |
31 |