b) allocating a new memory block of size new_size bytes, copying memory area with size equal the lesser of the new and the old sizes, and freeing the old block.
The realloc() function allocates, reallocates, or frees the block of memory specified by old_blk based on the following rules: If old_blk is NULL, a new block of memory of size bytes is allocated. If the size is zero, the free() function is called to release the memory pointed to by old_blk. Otherwise, realloc() reallocates space for an object of size bytes by: shrinking the size of the allocated memory block old_blk when size is smaller than the current size of old_blk extending the allocated size of the allocated memory block old_blk if there is a large enough block of unallocated memory immediately following old_blk allocating a new block with the appropriate size, and copying the contents of old_blk to this new block
Обсуждают сегодня