add function fc_strdup
parent
e53cbda01b
commit
85cc906b1d
3
HISTORY
3
HISTORY
|
|
@ -1,10 +1,11 @@
|
||||||
|
|
||||||
Version 1.40 2018-08-24
|
Version 1.40 2018-08-27
|
||||||
* add function conn_pool_parse_server_info and conn_pool_load_server_info
|
* add function conn_pool_parse_server_info and conn_pool_load_server_info
|
||||||
* support directive: #@add_annotation, for example:
|
* support directive: #@add_annotation, for example:
|
||||||
#@add_annotation CONFIG_GET /usr/lib/libshmcache.so /etc/libshmcache.conf
|
#@add_annotation CONFIG_GET /usr/lib/libshmcache.so /etc/libshmcache.conf
|
||||||
* add function fc_split_string and fc_match_delim
|
* add function fc_split_string and fc_match_delim
|
||||||
* add json_parser.[hc] for parse json array and map
|
* add json_parser.[hc] for parse json array and map
|
||||||
|
* add function fc_strdup
|
||||||
|
|
||||||
Version 1.39 2018-07-31
|
Version 1.39 2018-07-31
|
||||||
* add #@function REPLACE_VARS
|
* add #@function REPLACE_VARS
|
||||||
|
|
|
||||||
|
|
@ -2716,3 +2716,22 @@ bool ends_with(const char *str, const char *needle)
|
||||||
|
|
||||||
return memcmp(str + start_offset, needle, needle_len) == 0;
|
return memcmp(str + start_offset, needle, needle_len) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *fc_strdup(const char *str, const int len)
|
||||||
|
{
|
||||||
|
char *output;
|
||||||
|
|
||||||
|
output = (char *)malloc(len + 1);
|
||||||
|
if (output == NULL) {
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"malloc %d bytes fail",
|
||||||
|
__LINE__, len + 1);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
memcpy(output, str, len);
|
||||||
|
}
|
||||||
|
*(output + len) = '\0';
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -791,6 +791,14 @@ bool starts_with(const char *str, const char *needle);
|
||||||
*/
|
*/
|
||||||
bool ends_with(const char *str, const char *needle);
|
bool ends_with(const char *str, const char *needle);
|
||||||
|
|
||||||
|
/** strdup
|
||||||
|
* parameters:
|
||||||
|
* str: the string to duplicate
|
||||||
|
* len: the length of string
|
||||||
|
* return: the duplicated string, NULL for fail
|
||||||
|
*/
|
||||||
|
char *fc_strdup(const char *str, const int len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue