add function fc_memrchr

pull/37/head
YuQing 2020-02-08 09:19:10 +08:00
parent 90e61572c0
commit 798244cc1b
5 changed files with 31 additions and 1 deletions

View File

@ -1,9 +1,11 @@
Version 1.44 2020-02-03
Version 1.44 2020-02-08
* add test file src/tests/test_pthread_lock.c
* add uniq_skiplist.[hc]
* add function split_string_ex
* fast_mblock.[hc]: add init_args for init_func
* struct fast_task_info add field: nio_stage
* add function fc_memrchr
Version 1.43 2019-12-25
* replace function call system to getExecResult,

View File

@ -56,6 +56,7 @@ struct fast_task_info
int size; //alloc size
int length; //data length
int offset; //current offset
char nio_stage; //stage for network IO
int64_t req_count; //request count
TaskFinishCallback finish_callback;
struct nio_thread_data *thread_data;

View File

@ -2854,6 +2854,23 @@ const char *fc_memmem(const string_t *str, const string_t *needle)
return NULL;
}
const char *fc_memrchr(const char *str, const int ch, const int len)
{
const char *p;
p = str + len - 1;
while (p >= str)
{
if (*p == ch)
{
return p;
}
--p;
}
return NULL;
}
char *format_http_date(time_t t, BufferInfo *buffer)
{
struct tm tm_info;

View File

@ -844,6 +844,14 @@ char *fc_strdup(const char *str, const int len);
*/
const char *fc_memmem(const string_t *str, const string_t *needle);
/** memmem
* parameters:
* str: the string to match
* needle: the needle string
* return: the matched string, NULL for fail
*/
const char *fc_memrchr(const char *str, const int ch, const int len);
/** format HTTP Date as: Sat, 11 Mar 2017 21:49:51 GMT
* parameters:
* t: the time to format

View File

@ -55,6 +55,8 @@ typedef struct uniq_skiplist_iterator {
extern "C" {
#endif
#define uniq_skiplist_count(sl) (sl)->element_count
#define uniq_skiplist_init(factory, max_level_count, compare_func, free_func) \
uniq_skiplist_init_ex(factory, max_level_count, \
compare_func, free_func, 64 * 1024, \