src/atsc3_utils.c
block_t* block_Duplicate_from_position(block_t* src) {
	if(!__block_check_bounaries(__FUNCTION__, src)) return NULL;

	int32_t to_alloc_size = src->p_size - src->i_pos;
	if(to_alloc_size < 0) {
		_ATSC3_UTILS_WARN("block_Duplicate_from_position: block: %p, p_size was: %u, but i_pos: %u, realloc to size: %u, returning NULL", src, src->p_size, src->i_pos, to_alloc_size);
		return NULL;
	}

	block_t* dest = block_Alloc(to_alloc_size);
	memcpy(dest->p_buffer, &src->p_buffer[src->i_pos], to_alloc_size);
	dest->i_pos = 0;

	return dest;
}
/**
 *
 * this will return a new block starting at src->i_pos to the end of the payload size
 */
this will return a new block starting at src->i_pos to the end of the payload size
this will return a new block starting at src - > i_pos to the end of the payload size
block_t* block_Duplicate_from_position(block_t* src) {
	if(!__block_check_bounaries(__FUNCTION__, src)) return NULL;
	int32_t to_alloc_size = src->p_size - src->i_pos;
	if(to_alloc_size < 0) {
		_ATSC3_UTILS_WARN("block_Duplicate_from_position: block: %p, p_size was: %u, but i_pos: %u, realloc to size: %u, returning NULL", src, src->p_size, src->i_pos, to_alloc_size);
		return NULL;
	}
	block_t* dest = block_Alloc(to_alloc_size);
	memcpy(dest->p_buffer, &src->p_buffer[src->i_pos], to_alloc_size);
	dest->i_pos = 0;
	return dest;
}
block_t * block_Duplicate_from_position ( block_t * src ) { if ( ! __block_check_bounaries ( __FUNCTION__ , src ) ) return NULL ; int32_t to_alloc_size = src -> p_size - src -> i_pos ; if ( to_alloc_size < 0 ) { _ATSC3_UTILS_WARN ( " " , src , src -> p_size , src -> i_pos , to_alloc_size ) ; return NULL ; } block_t * dest = block_Alloc ( to_alloc_size ) ; memcpy ( dest -> p_buffer , & src -> p_buffer [ src -> i_pos ] , to_alloc_size ) ; dest -> i_pos = 0 ; return dest ; }
this will return a new block starting at src->i_pos to the end of the payload size
this will return a new block starting at src - > i_pos to the end of the payload size