nice_size()

nice_size()#

nice_size() formats a byte count into a human-readable string with appropriate units (B, KB, MB, etc.), using either base-1000 or base-1024 scaling.

Prototype

void nice_size(
    char *bf,      size_t bfsize,
    uint64_t bytes, BOOL   b1024
);

Parameters

Key

Type

Description

bf

char *

Buffer to store the formatted size string.

bfsize

size_t

Size of the buffer bf.

bytes

uint64_t

The number of bytes to format.

b1024

BOOL

If TRUE, uses base-1024 (binary units); otherwise, uses base-1000 (decimal units).


Return Value

None.

Notes

The function ensures that the formatted string fits within bfsize and selects the most appropriate unit for readability.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples