Skip to content

Commit

Permalink
core: add bigint2str helper function
Browse files Browse the repository at this point in the history
 - convert bigint to string
  • Loading branch information
ovidiusas committed Apr 29, 2024
1 parent 999b8ac commit 43dfdc8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ut.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ static inline char* double2str(double d, int* len)
return int2str_buf[buf];
}

#define BIGINT2STR_MAX_LEN INT2STR_MAX_LEN
static inline char* bigint2str(long long l, int* len)
{
unsigned int buf;

buf = getstrbufindex();
*len = snprintf(int2str_buf[buf], INT2STR_MAX_LEN - 1, "%lld", l);
int2str_buf[buf][*len] = '\0';

return int2str_buf[buf];
}

/* faster memchr version */
static inline char* q_memchr(char* p, int c, unsigned int size)
Expand Down

0 comments on commit 43dfdc8

Please sign in to comment.