First version of alignment functions (imported from suma* programs)

This commit is contained in:
Celine Mercier
2016-05-11 16:36:23 +02:00
parent 3567681339
commit b3c47809da
27 changed files with 1991 additions and 43 deletions

View File

@ -65,6 +65,12 @@ char* obi_format_date(time_t date)
struct tm* tmp;
formatted_time = (char*) malloc(FORMATTED_TIME_LENGTH*sizeof(char));
if (formatted_time == NULL)
{
obi_set_errno(OBI_MALLOC_ERROR);
obidebug(1, "\nError allocating memory to format a date");
return NULL;
}
tmp = localtime(&date);
if (tmp == NULL)
@ -84,3 +90,27 @@ char* obi_format_date(time_t date)
return formatted_time;
}
void* obi_get_memory_aligned_on_16(int size, int* shift)
{
void* memory;
*shift = 0;
memory = (void*) malloc(size);
if (memory == NULL)
{
obi_set_errno(OBI_MALLOC_ERROR);
obidebug(1, "\nError allocating memory");
return NULL;
}
while ((((long long unsigned int) (memory))%16) != 0)
{
memory++;
(*shift)++;
}
return (memory);
}