MCPcopy Create free account
hub / github.com/antirez/botlib / sdsll2str

Function sdsll2str

sds.c:450–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448 * representation stored at 's'. */
449#define SDS_LLSTR_SIZE 21
450int 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. */
482int sdsull2str(char *s, unsigned long long v) {

Callers 2

sdsfromlonglongFunction · 0.85
sdscatfmtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected