Compare commits
4 Commits
9864bd39be
...
7354132131
| Author | SHA1 | Date |
|---|---|---|
|
|
7354132131 | |
|
|
128e04b2ec | |
|
|
233b644ce5 | |
|
|
e009d750a5 |
4
HISTORY
4
HISTORY
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
Version 1.84 2026-01-16
|
||||
* fast_task_queue.h: add function free_queue_task_arg_offset
|
||||
* add function double2str and double_to_comma_str
|
||||
|
||||
Version 1.83 2025-11-15
|
||||
* fast_task_queue.h: remove field finish_callback
|
||||
|
||||
|
|
|
|||
2
INSTALL
2
INSTALL
|
|
@ -21,5 +21,5 @@ Debian, Ubuntu etc.:
|
|||
# the command lines as:
|
||||
|
||||
git clone https://github.com/happyfish100/libfastcommon.git
|
||||
cd libfastcommon; git checkout V1.0.83
|
||||
cd libfastcommon; git checkout V1.0.84
|
||||
./make.sh clean && ./make.sh && sudo ./make.sh install
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
%define CommitVersion %(echo $COMMIT_VERSION)
|
||||
|
||||
Name: libfastcommon
|
||||
Version: 1.0.83
|
||||
Version: 1.0.84
|
||||
Release: 1%{?dist}
|
||||
Summary: c common functions library extracted from my open source projects FastDFS
|
||||
License: LGPL
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
static int task_alloc_init(struct fast_task_info *task,
|
||||
struct fast_task_queue *queue)
|
||||
{
|
||||
task->arg = (char *)task + ALIGNED_TASK_INFO_SIZE + queue->padding_size;
|
||||
task->arg = (char *)task + free_queue_task_arg_offset(queue);
|
||||
task->send.ptr = &task->send.holder;
|
||||
task->send.ptr->size = queue->min_buff_size;
|
||||
if (queue->malloc_whole_block) {
|
||||
|
|
|
|||
|
|
@ -236,6 +236,11 @@ static inline int free_queue_alloc_connections(struct fast_task_queue *queue)
|
|||
return queue->allocator.info.element_total_count;
|
||||
}
|
||||
|
||||
static inline int free_queue_task_arg_offset(struct fast_task_queue *queue)
|
||||
{
|
||||
return ALIGNED_TASK_INFO_SIZE + queue->padding_size;
|
||||
}
|
||||
|
||||
int free_queue_get_new_buffer_size(const int min_buff_size,
|
||||
const int max_buff_size, const int expect_size, int *new_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -3178,7 +3178,7 @@ key_t fc_ftok(const char *path, const int proj_id)
|
|||
return (((proj_id & 0xFF) << 24) | (hash_code & 0xFFFFFF));
|
||||
}
|
||||
|
||||
static void add_thousands_separator(char *str, const int len)
|
||||
static int add_thousands_separator(char *str, const int len)
|
||||
{
|
||||
int new_len;
|
||||
int addings;
|
||||
|
|
@ -3191,7 +3191,7 @@ static void add_thousands_separator(char *str, const int len)
|
|||
|
||||
if (len <= 3)
|
||||
{
|
||||
return;
|
||||
return len;
|
||||
}
|
||||
|
||||
if (*str == '-')
|
||||
|
|
@ -3227,6 +3227,8 @@ static void add_thousands_separator(char *str, const int len)
|
|||
add_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return new_len;
|
||||
}
|
||||
|
||||
const char *int2str(const int n, char *buff, const bool thousands_separator)
|
||||
|
|
@ -4523,3 +4525,33 @@ int fc_compare_int64_ptr(const int64_t *n1, const int64_t *n2)
|
|||
{
|
||||
return fc_compare_int64(*n1, *n2);
|
||||
}
|
||||
|
||||
const char *double2str(const double d, const int scale,
|
||||
char *buff, const bool thousands_separator)
|
||||
{
|
||||
int len;
|
||||
int front_len;
|
||||
int tail_len;
|
||||
int new_len;
|
||||
char *point;
|
||||
char fragment[32];
|
||||
|
||||
len = fc_ftoa(d, scale, buff);
|
||||
*(buff + len) = '\0';
|
||||
if (!thousands_separator) {
|
||||
return buff;
|
||||
}
|
||||
|
||||
if (scale <= 0) {
|
||||
add_thousands_separator(buff, len);
|
||||
return buff;
|
||||
}
|
||||
|
||||
tail_len = 1 + scale;
|
||||
front_len = len - tail_len;
|
||||
point = buff + front_len;
|
||||
memcpy(fragment, point, tail_len + 1);
|
||||
new_len = add_thousands_separator(buff, front_len);
|
||||
memcpy(buff + new_len, fragment, tail_len + 1);
|
||||
return buff;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1191,6 +1191,23 @@ static inline const char *long_to_comma_str(const int64_t n, char *buff)
|
|||
return long2str(n, buff, true);
|
||||
}
|
||||
|
||||
/** convert double to string
|
||||
* parameters:
|
||||
* d: the double number
|
||||
* scale: number of decimal places (round off)
|
||||
* buff: output buffer
|
||||
* thousands_separator: if add thousands separator
|
||||
* return: string buffer
|
||||
*/
|
||||
const char *double2str(const double d, const int scale,
|
||||
char *buff, const bool thousands_separator);
|
||||
|
||||
static inline const char *double_to_comma_str(const double d,
|
||||
const int scale, char *buff)
|
||||
{
|
||||
return double2str(d, scale, buff, true);
|
||||
}
|
||||
|
||||
const char *bytes_to_human_str(const int64_t bytes, char *buff);
|
||||
|
||||
/** if the string starts with the needle string
|
||||
|
|
|
|||
Loading…
Reference in New Issue