view 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
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include "object.h"
#include "sys.h"

#define ALIGN_16BYTE 16

int malloc_align16(void *free, void *aligned, int size)
{
  char *index;
  unsigned int *f=(unsigned int *)free,*a=(unsigned int *)aligned;

  if (free == NULL || aligned == NULL || size <= 0) return(-1);

  index = (char *)malloc(size + ALIGN_16BYTE);
  if (index == NULL)
    {
      return(-1);
    }

  *f = *a = (unsigned int)index;
  if (((unsigned int)index % ALIGN_16BYTE) != 0)
    {
      index += ALIGN_16BYTE - ((unsigned int)index % ALIGN_16BYTE);
      *a = (unsigned int)index;
    }
  return(0);
}