Changeset cfd04c4 in mainline
- Timestamp:
- 2025-10-09T15:57:48Z (5 weeks ago)
- Branches:
- master
- Children:
- 0cf3d5f
- Parents:
- c111da2
- File:
-
- 1 edited
-
uspace/lib/c/generic/capa.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/capa.c
rc111da2 rcfd04c4 199 199 } 200 200 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 */ 201 207 errno_t capa_format(capa_spec_t *capa, char **rstr) 202 208 { … … 233 239 } 234 240 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 */ 235 248 errno_t capa_format_buf(capa_spec_t *capa, char *buf, size_t bufsize) 236 249 { … … 263 276 } 264 277 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 */ 265 288 errno_t capa_blocks_format(uint64_t nblocks, size_t block_size, 266 289 char **rptr) … … 273 296 } 274 297 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 */ 275 312 void capa_blocks_format_buf(uint64_t nblocks, size_t block_size, 276 char *buf, size_t b size)313 char *buf, size_t bufsize) 277 314 { 278 315 capa_spec_t capa; … … 283 320 284 321 /* Should not get range error because of nblocks * block_size limits */ 285 rc = capa_format_buf(&capa, buf, b size);322 rc = capa_format_buf(&capa, buf, bufsize); 286 323 assert(rc == EOK); 287 324 (void)rc; … … 328 365 } 329 366 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 */ 330 373 errno_t capa_parse(const char *str, capa_spec_t *capa) 331 374 {
Note:
See TracChangeset
for help on using the changeset viewer.
