[#BloombergLP-bdlbb-BlobUtil-getContiguousRangeOrCopy]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlbb.adoc[bdlbb]::xref:BloombergLP/bdlbb/BlobUtil.adoc[BlobUtil]::getContiguousRangeOrCopy
:relfileprefix: ../../../
:mrdocs:

Return a contiguous view of blob data, copying into a buffer if needed&period;

== Synopsis

Declared in `&lt;bdlbb&lowbar;blobutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
char*
getContiguousRangeOrCopy(
    char* dstBuffer,
    xref:BloombergLP/bdlbb/Blob.adoc[Blob] const& srcBlob,
    int position,
    int length,
    int alignment = 1);
----

== Description

Return the address of the byte at the specified `position` in the specified `srcBlob`, if that address is aligned to the optionally specified `alignment` and the specified `length` bytes are stored contiguously&semi; otherwise, _copy_ `length` bytes to the specified buffer `dstBuffer`, and return `dstBuffer`&period; If alignment is not specified, none is enforced&period; (An address is aligned to A if, when converted to an integral value `a`, `a &amp; (A &hyphen; 1)` is 0&period;) The behavior of this function is undefined unless `0 &lt; length`, `0 &lt;&equals; position`, `alignment` is a power of two, `dstBuffer` is aligned as required, `dstBuffer` has room for `length` bytes, and `position &lt;&equals; srcBlob&period;totalSize() &hyphen; length`&period;

== Return Value

address of the contiguous range in `srcBlob`, or `dstBuffer` if a copy was required

== Parameters

[cols="1,4"]
|===
| Name| Description
| *dstBuffer*
| fallback contiguous buffer used when a copy is needed
| *srcBlob*
| source blob
| *position*
| starting byte offset in `srcBlob`
| *length*
| number of bytes required contiguously
| *alignment*
| required alignment of the returned address
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
