Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CAtlIsapiBuffer Class 

This class is an efficient buffer that manages its own memory and is used by the ATL Server code to buffer data in CHttpResponse and CAtlHttpClient.


template <
   DWORD dwSizeT = ATL_ISAPI_BUFFER_SIZE
>
class CAtlIsapiBuffer

Parameters

dwSizeT

The size of the statically allocated buffer in bytes.

This class represents a dynamically resizable string buffer. Data can be written to the buffer using CAtlIsapiBuffer::Append or CAtlIsapiBuffer::operator +=. Data can be retrieved from the buffer using CAtlIsapiBuffer::operator LPCSTR.

For efficiency, each instance of this class statically allocates a buffer of dwSizeT bytes. Typically, this static buffer is used by calls to CAtlIsapiBuffer::Append until the amount of data written exceeds the size of the static buffer, at which point the class creates a new buffer and copies the existing data into it. As more data is appended, the buffer grows to accommodate it. The buffer grows in fixed size blocks or just enough to accommodate the new data, whichever is greater.

The class provides the CAtlIsapiBuffer::Alloc, CAtlIsapiBuffer::ReAlloc, and CAtlIsapiBuffer::Free methods to allow control over memory allocations and increase efficiency when use of the buffer is well understood.

Note that if the buffered data never exceeds the size of the static allocation, using this class allows you to avoid any run-time memory allocations and achieve significant speed improvements. If data is written to the static buffer initially, but the data eventually exceeds the size of the static allocation, there is a run-time cost associated with copying data from the static buffer to the dynamic buffer and a memory cost since the static buffer is no longer used.

You may want to define your own value for ATL_ISAPI_BUFFER_SIZE if you use the CHttpResponse and CAtlHttpClient classes. These classes have CAtlIsapiBuffer members with the static buffer initialized to the size of this macro. You can define ATL_ISAPI_BUFFER_SIZE to be 0 if you regularly set the size of the buffer programmatically, for example by calling CHttpResponse::SetBufferLimit, to avoid wasting memory when the size of the buffered data is larger than the statically allocated memory.

NoteNote

A CAtlIsapiBuffer object cannot hold more than 4MB on Win9x operating systems.

Header: atlutil.h

Community Additions

ADD
Show:
© 2015 Microsoft