Write the long long 'bytes' value as a string in a way that is parsable * inside keydb.conf. If possible uses the GB, MB, KB notation. */
| 1514 | /* Write the long long 'bytes' value as a string in a way that is parsable |
| 1515 | * inside keydb.conf. If possible uses the GB, MB, KB notation. */ |
| 1516 | int rewriteConfigFormatMemory(char *buf, size_t len, long long bytes) { |
| 1517 | int gb = 1024*1024*1024; |
| 1518 | int mb = 1024*1024; |
| 1519 | int kb = 1024; |
| 1520 | |
| 1521 | if (bytes && (bytes % gb) == 0) { |
| 1522 | return snprintf(buf,len,"%lldgb",bytes/gb); |
| 1523 | } else if (bytes && (bytes % mb) == 0) { |
| 1524 | return snprintf(buf,len,"%lldmb",bytes/mb); |
| 1525 | } else if (bytes && (bytes % kb) == 0) { |
| 1526 | return snprintf(buf,len,"%lldkb",bytes/kb); |
| 1527 | } else { |
| 1528 | return snprintf(buf,len,"%lld",bytes); |
| 1529 | } |
| 1530 | } |
| 1531 | |
| 1532 | /* Rewrite a simple "option-name <bytes>" configuration option. */ |
| 1533 | void rewriteConfigBytesOption(struct rewriteConfigState *state, const char *option, long long value, long long defvalue) { |
no outgoing calls
no test coverage detected