Page 92 - DCAP408_WEB_PROGRAMMING
P. 92

Windows Programming




                    Notes              SIZE  BlockSize
                                   );
                                   Parameters:
                                   MemoryPool
                                   It defines the address of memory pool to be initialized.
                                   MemorySize
                                   It indicates the total size of the memory.

                                   BlockSize
                                   It indicates the size of the memory block that will be allocated.
                                   Return value:

                                   TRUE on success or FALSE on failure.
                                   Description:
                                   Function initializes memory pool, for particular memory address. The memory address must
                                   be passed to stFixedMemAlloc and stFixedMemFree functions to assign memory blocks in this
                                   memory. Size of the every allocated block is at all times fixed. This function does not set the last
                                   error code on failure. Access to  the fixed memory is never coordinated. If it is mandatory it
                                   should be implemented.
                                   Function will be not compiled when functions accountable for memory management are disabled,
                                   by setting ST_USE_FIXMEM for 0.




                                      Task  Make distinction between stFixedMemFree function and stFixedMemInit function.

                                   Self Assessment

                                   Fill in the blanks:

                                   6.  .................... blocks allocation algorithm has been established to permit technique of memory
                                       allocation in static time, separately to number of allocated blocks.
                                   7.  The .................... constant comprises information whether functions for fixed size memory
                                       blocks allocation are incorporated or expelled from compilation.

                                   5.4 Changing the Size of a Memory Block

                                   Frequently you do not know for certain how large a block you will eventually need at the time
                                   you must start to use the block.


                                          Example: The block might be a buffer that you use to hold a line being read from a file;
                                   regardless of how long you make the buffer originally, you may encounter a line that is longer.
                                   You can make the block longer by calling realloc. This function is affirmed in ‘stdlib.h’.

                                   Function: void * realloc (void *ptr, size_t newsize)
                                   The realloc function modifies the size of the block whose address is ptr to be newsize.




          86                                LOVELY PROFESSIONAL UNIVERSITY
   87   88   89   90   91   92   93   94   95   96   97