X11 Work Bench Toolkit 1.0
basic 'buffered I/O' object structure for 'FileBuf' APIs More...
|struct __file_help_buf__ *||pPrev|
|pointer to 'previous' item in linked list (NULL for owner object) |
|struct __file_help_buf__ *||pNext|
|pointer to 'next' item in linked list (NULL for last object) |
|size of entire buffer |
|number of bytes of valid data |
|number of lines in 'cData' when ppLineBuf not NULL |
|size of memory block pointed to by 'ppLineBuf' |
|various bit flags |
|array of pointers to beginning of each line (WBAlloc'd TODO: make it part of 'cData'?) |
|char||cData [sizeof(char *)]|
|the data itself (aligned to size of a pointer) |
basic 'buffered I/O' object structure for 'FileBuf' APIs
This structure is intended to assist implementing buffered I/O for files that contain multiple lines separated by linefeeds. A 'file edit' window or dialog control could use one of these objects to assist with displaying and editing text based on the contents of a file. It would also be possible to construct a file_help_buf_t object from a memory buffer as well as from a text file.
TODO: 'ppLineBuf' should point to an area within cData. If 'pNext' is valid, subsequent lines could be pointed to by the 'ppLineBuf' within the structure pointed to by 'pNext'. In this way line pointers can be re-structured without re-allocating memory. Additionally, there is no reason why lines must be contiguous, so inserting and removing lines can make use of the additional allocated space pointed to by 'pNext'.
As it would become fragmented, it would also be a good idea to re-build the structure periodically using FBParseFileBuf()