Step 7: Using these properties, allocate memory for a record buffer

<< Click to Display Table of Contents >>

Navigation:  Application development > Introduction to BDE programming > BDE Programming in C++Builder > Basic procedure >

Step 7: Using these properties, allocate memory for a record buffer

Previous pageReturn to chapter overviewNext page

The next step is to make available a memory buffer for record data. A later step will read one record’s worth of data into this buffer. From there, the values of individual fields can be extracted for use. Allocate memory space for the record buffer using the C++Builder function malloc. The size of this buffer needs to be the size of the record as indicated by the DbiGetCursorProps (in the preceding step). Use the iRecBufSize field of the CURProps structure with the malloc function.

void __fastcall TForm1::Button1Click(TObject *Sender)

{

 …

unsigned char* pRecBuf; // Pointer to the record buffer

 …

 pRecBuf = (unsigned char*) malloc(curProps.iRecBufSize);

 …

}