| 448 | * representation stored at 's'. */ |
| 449 | #define SDS_LLSTR_SIZE 21 |
| 450 | int sdsll2str(char *s, long long value) { |
| 451 | char *p, aux; |
| 452 | unsigned long long v; |
| 453 | size_t l; |
| 454 | |
| 455 | /* Generate the string representation, this method produces |
| 456 | * an reversed string. */ |
| 457 | v = (value < 0) ? -value : value; |
| 458 | p = s; |
| 459 | do { |
| 460 | *p++ = '0'+(v%10); |
| 461 | v /= 10; |
| 462 | } while(v); |
| 463 | if (value < 0) *p++ = '-'; |
| 464 | |
| 465 | /* Compute length and add null term. */ |
| 466 | l = p-s; |
| 467 | *p = '\0'; |
| 468 | |
| 469 | /* Reverse the string. */ |
| 470 | p--; |
| 471 | while(s < p) { |
| 472 | aux = *s; |
| 473 | *s = *p; |
| 474 | *p = aux; |
| 475 | s++; |
| 476 | p--; |
| 477 | } |
| 478 | return l; |
| 479 | } |
| 480 | |
| 481 | /* Identical sdsll2str(), but for unsigned long long type. */ |
| 482 | int sdsull2str(char *s, unsigned long long v) { |
no outgoing calls
no test coverage detected