Changeset cfd04c4 in mainline


Ignore:
Timestamp:
2025-10-09T15:57:48Z (5 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
0cf3d5f
Parents:
c111da2
Message:

Add docblocks to capa functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/capa.c

    rc111da2 rcfd04c4  
    199199}
    200200
     201/** Format capacity as string into a newly allocated buffer.
     202 *
     203 * @param capa Capacity
     204 * @param rstr Place to store pointer to newly allocated string
     205 * @return EOK on success or an error code
     206 */
    201207errno_t capa_format(capa_spec_t *capa, char **rstr)
    202208{
     
    233239}
    234240
     241/** Format capacity as string into an existing buffer.
     242 *
     243 * @param capa Capacity
     244 * @param buf Buffer for storing string
     245 * @param bufsize Size of buffer in bytes
     246 * @return EOK on success or an error code
     247 */
    235248errno_t capa_format_buf(capa_spec_t *capa, char *buf, size_t bufsize)
    236249{
     
    263276}
    264277
     278/** Format capacity of n blocks as string into a newly allocated buffer.
     279 *
     280 * This computes the total capacity of the blocks, simplifies it
     281 * and formats it as string.
     282 *
     283 * @param nblocks Number of blocks
     284 * @param block_size Size of each block in bytes
     285 * @param rstr Place to store pointer to newly allocated string
     286 * @return EOK on success or an error code
     287 */
    265288errno_t capa_blocks_format(uint64_t nblocks, size_t block_size,
    266289    char **rptr)
     
    273296}
    274297
     298/** Format capacity of n blocks as string into an existing buffer.
     299 *
     300 * This computes the total capacity of the blocks, simplifies it
     301 * and formats it as string.
     302 *
     303 * This function does not return error. If the buffer is too small,
     304 * the string will be truncated. To make sure it is not truncated,
     305 * bufsize should be at least CAPA_BLOCKS_BUFSIZE.
     306 *
     307 * @param nblocks Number of blocks
     308 * @param block_size Size of each block in bytes
     309 * @param buf Buffer for storing string
     310 * @param bufsize Size of buffer in bytes
     311 */
    275312void capa_blocks_format_buf(uint64_t nblocks, size_t block_size,
    276     char *buf, size_t bsize)
     313    char *buf, size_t bufsize)
    277314{
    278315        capa_spec_t capa;
     
    283320
    284321        /* Should not get range error because of nblocks * block_size limits */
    285         rc = capa_format_buf(&capa, buf, bsize);
     322        rc = capa_format_buf(&capa, buf, bufsize);
    286323        assert(rc == EOK);
    287324        (void)rc;
     
    328365}
    329366
     367/** Parse string as capacity specification.
     368 *
     369 * @param str String (e.g. "100 kB")
     370 * @param capa Place to store capacity
     371 * @return EOK on success or an error code
     372 */
    330373errno_t capa_parse(const char *str, capa_spec_t *capa)
    331374{
Note: See TracChangeset for help on using the changeset viewer.