# mco_disk_get_allocated_space
RT

> This function collects information about the size of allocated and used pages in the database file.

### Prototype

        MCO_RET mco_disk_get_allocated_space(
            /* IN */ mco_db_h con,
            /* OUT */ mco_offs_t* allocated,
            /* OUT */ mco_offs_t* used);

### Arguments

con
The database handle for a database connection
allocated
A pointer to a variable to receive the total size of all allocated pages (both used and free)
used
A pointer to a variable to receive the total size of used pages

### Description

> This function collects information about the size and distribution of allocated and used pages in the database file. It provides a summary view of physical space usage without exposing fine-grained fragmentation details.

> The function is similar to `mco_disk_get_alloc_info`, but it does not return a histogram of hole counters. As a result, it has lower overhead and is intended for lightweight monitoring and diagnostics rather than detailed fragmentation analysis.

### Return Codes

> MCO_S_OK
> The function completed successfully.
> MCO_E_UNSUPPORTED
> Unsupported call.

### Example

            ...
            #define CHECK(func)  { MCO_RET rc_ = func; if (rc_ != MCO_S_OK) { \
                printf("\nCall \"" #func "\" at %s:%d failed , code = %d\n\t(%s)\n", __FILE__, __LINE__, rc_, mco_ret_string(rc_, 0)); \
                dbg_exit(rc_); }}

            ...
            mco_disk_alloc_info_t unaligned, aligned;
            mco_offs_t allocated, used, total_allocated, total_used;
            ...
            CHECK(mco_disk_get_alloc_info(db, &unaligned, &aligned));
            CHECK(mco_disk_get_allocated_space(db, &allocated, &used));

            total_allocated = unaligned.allocated + aligned.allocated;
            total_used = unaligned.used + aligned.used;
            ...
            printf("alloc_info:      alloc %lld(bytes), used %lld(bytes)\n",
                (mco_int8)total_allocated, (mco_int8)total_used);
            printf("allocated_space: alloc %lld(bytes), used %lld(bytes)\n\n",
                (mco_int8)allocated, (mco_int8)used);
            ...

### Files

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