add function fc_init_buffer

pull/37/head
YuQing 2020-03-13 15:09:08 +08:00
parent 4d653d1b3e
commit 21336eee3e
2 changed files with 22 additions and 0 deletions

View File

@ -3020,3 +3020,17 @@ int fc_ceil_prime(const int n)
return i; return i;
} }
int fc_init_buffer(BufferInfo *buffer, const int buffer_size)
{
buffer->buff = (char *)malloc(buffer_size);
if (buffer->buff == NULL)
{
logError("file: "__FILE__", line: %d, "
"malloc %d bytes fail", __LINE__, buffer_size);
return ENOMEM;
}
buffer->alloc_size = buffer_size;
buffer->length = 0;
return 0;
}

View File

@ -919,6 +919,14 @@ int fc_floor_prime(const int n);
*/ */
int fc_ceil_prime(const int n); int fc_ceil_prime(const int n);
/** init buffer
* parameters:
* buffer: the buffer to init
* buffer_size: the buffer size
* return: error no, 0 success, != 0 fail
*/
int fc_init_buffer(BufferInfo *buffer, const int buffer_size);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif