Identical sdsll2str(), but for unsigned long long type. */
| 515 | |
| 516 | /* Identical sdsll2str(), but for unsigned long long type. */ |
| 517 | int sdsull2str(char *s, unsigned long long v) { |
| 518 | char *p, aux; |
| 519 | size_t l; |
| 520 | |
| 521 | /* Generate the string representation, this method produces |
| 522 | * a reversed string. */ |
| 523 | p = s; |
| 524 | do { |
| 525 | *p++ = '0'+(v%10); |
| 526 | v /= 10; |
| 527 | } while(v); |
| 528 | |
| 529 | /* Compute length and add null term. */ |
| 530 | l = p-s; |
| 531 | *p = '\0'; |
| 532 | |
| 533 | /* Reverse the string. */ |
| 534 | p--; |
| 535 | while(s < p) { |
| 536 | aux = *s; |
| 537 | *s = *p; |
| 538 | *p = aux; |
| 539 | s++; |
| 540 | p--; |
| 541 | } |
| 542 | return l; |
| 543 | } |
| 544 | |
| 545 | /* Create an sds string from a long long value. It is much faster than: |
| 546 | * |