First version of alignment functions (imported from suma* programs)
This commit is contained in:
30
src/utils.c
30
src/utils.c
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user