In a multi-user environment, jobs with various memory requirements are submitted to the computer system, and the operating system allocates a portion of memory to each job, using some memory-management scheme.
One popular scheme maintains a circular doubly-linked list of free memory blocks.
When a memory request is received, this list is searched to locate the first available block that is large enough to satisfy the request.
An appropriate portion of this block is allocated to the job, and any remaining portion remains on the free list.
Write and test a function to implement this first-fit memory-management scheme.
Assume that memory blocks are represented as classes (or struts) that contain the beginning address of an available block and its size, together with the links necessary to maintain a circular doubly-linked list.
The function should return the address of the allocated block or an indication that the request cannot be satisfied.