mco_db_detach_dev

Reduce database memory by detaching a memory device (simplified interface).

Prototype

    MCO_RET mco_db_detach_dev(
        /*IN*/ const char *db_name,
        /*IN*/ mco_device_t *dev
    );

Arguments

db_name
Name of the open database from which to detach the device.
dev
Pointer to a mco_device_t structure describing the memory device to detach. Only devices with assignment = MCO_MEMORY_ASSIGN_PIPE_BUF are supported.

Description

This function is a simplified wrapper around mco_db_detach_dev_ctx() that passes a NULL context. It reduces the available memory of an opened database by detaching a previously added memory device.

It is typically used to release unused memory segments when system resources need to be reclaimed. The operation requires exclusive access to the database and will fail if active transactions are present.

Important: Only devices assigned as MCO_MEMORY_ASSIGN_PIPE_BUF can be detached. Attempting to detach other device types will result in MCO_E_UNSUPPORTED.

If the device contains active allocations, the detachment may be deferred until those objects are freed (indicated by return code MCO_S_DEFERRED_DELETE).

Return Codes

MCO_S_OK
Device successfully detached and memory released.
MCO_S_DEFERRED_DELETE
Device detachment has been scheduled but cannot complete immediately (e.g., due to active allocations).
MCO_E_UNSUPPORTED
The device assignment type is not MCO_MEMORY_ASSIGN_PIPE_BUF.
Other error codes
May include connection errors, lock failures, or internal system errors.

Files

Header file:
mco.h
Source file:
mcodb.c
Library:
libmcolib.a