feat/api #46

Open
Gregor Weiss wants to merge 56 commits from feat/api into main
Showing only changes of commit df2ad56f14 - Show all commits

View file

@ -253,82 +253,6 @@ eas3_init_stream(uchar* memory, uint32 size, char instr)
aux_pos += chunck_len; \ aux_pos += chunck_len; \
} }
void
eas3_emit_chunck(span *const stream, const uchar* chunck, const uint64 size)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64 Lreq;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
assert(chunck);
/*--------------------------------------------------------*\
! Evaluate the memory block size if the current chunck of !
! data is written to the stream. !
\*--------------------------------------------------------*/
Lreq = (eas3_bytes_used(stream) + size);
/*--------------------------------------------------------*\
! Check if the enough memory has been allocated for the !
! stream to store the additional data chunck. !
\*--------------------------------------------------------*/
if(Lreq > stream->Lmax)
{
/*--------------------------------------------------------*\
! If the stream is not large enough, check if this is due !
! to an error encountered in a previous writing operation !
\*--------------------------------------------------------*/
if(!stream->error)
{
/*--------------------------------------------------------*\
! If the error flag is not set, increase the stream size !
! until it is large enough to store the additional data !
! chunck. !
\*--------------------------------------------------------*/
while(Lreq > stream->Lmax)
{
stream->Lmax += stream->size_incr + size;
stream->size_incr = (uint64)(stream->Lmax / 2);
}
/*--------------------------------------------------------*\
! Reallocate the stream data block. !
\*--------------------------------------------------------*/
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
stream->error |= 1;
stream->Lmax = 0;
return;
}
}
else
{
/*--------------------------------------------------------*\
! Exit to function caller if error flag has been set. !
\*--------------------------------------------------------*/
return;
}
}
/*--------------------------------------------------------*\
! Copy the additional data to the stream memory block. !
\*--------------------------------------------------------*/
memcpy(stream->memory + stream->L, chunck, size);
/*--------------------------------------------------------*\
! Increment the number of bytes written to the stream with !
! the size of the newly added data chunck. !
\*--------------------------------------------------------*/
stream->L += size;
}
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) ! ! FUNCTION NAME: void *test(void) !
! -------------- ! ! -------------- !
@ -420,76 +344,6 @@ eas3_get_chunck(span *const stream, const uint64 size)
} }
} }
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar
eas3_terminate_stream(span *stream, span *const packed_stream)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
if(packed_stream)
{
if(stream->error)
{
return 1;
}
else if(stream->L != stream->Lmax)
{
stream->Lmax = stream->L;
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
fprintf(stderr, MEMERROR);
stream->Lmax = 0;
return 1;
}
}
packed_stream->memory = stream->memory;
packed_stream->access = stream->memory;
packed_stream->size = stream->L;
packed_stream->position = 0;
packed_stream->L = stream->L;
}
else
{
free(stream->memory);
}
free(stream);
return 0;
}
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------------------*\
! ! ! !
! DESCRIPTION: ! ! DESCRIPTION: !