<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def memory_allocation(library, session, size, extended=False):
 """Allocates memory from a resource's memory region. Corresponds to viMemAlloc* functions of the VISA library. :param library: the visa library wrapped by ctypes. :param session: Unique logical identifier to a session. :param size: Specifies the size of the allocation. :param extended: Use 64 bits offset independent of the platform. :return: offset of the allocated memory, return value of the library call. :rtype: offset, :class:`pyvisa.constants.StatusCode` """

    offset = ViBusAddress()
    if extended:
        ret = library.viMemAllocEx(session, size, byref(offset))
    else:
        ret = library.viMemAlloc(session, size, byref(offset))
    return offset, ret