Re: [PATCH 4/4] lib: rename json_strcpy to json_strdup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 21, 2023 at 12:24:26PM +0200, Ahmad Fatoum wrote:
> json_strcpy is an unfortunate name for a function that allocates
> memory. Rename it to json_strdup instead.

s/json_strcpy/jsmn_strcpy/
s/json_strdup/jsmn_strdup/

Sascha

> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
>  include/jsmn.h   | 2 +-
>  lib/jsmn.c       | 2 +-
>  test/self/json.c | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/jsmn.h b/include/jsmn.h
> index 64b3b535ab6e..156ae2086439 100644
> --- a/include/jsmn.h
> +++ b/include/jsmn.h
> @@ -153,7 +153,7 @@ JSMN_API const jsmntok_t *jsmn_locate(const char *path[], const char *json,
>   * value does not exist or is not a string. The caller takes ownership of the
>   * pointer returned.
>   */
> -JSMN_API char *jsmn_strcpy(const char *path[], const char *json, const jsmntok_t *tokens);
> +JSMN_API char *jsmn_strdup(const char *path[], const char *json, const jsmntok_t *tokens);
>  
>  #ifdef __cplusplus
>  }
> diff --git a/lib/jsmn.c b/lib/jsmn.c
> index 9e624f7518ad..10a77886a8bd 100644
> --- a/lib/jsmn.c
> +++ b/lib/jsmn.c
> @@ -483,7 +483,7 @@ JSMN_API const jsmntok_t *jsmn_locate(const char *path[], const char *json,
>  	return tokens;
>  }
>  
> -JSMN_API char *jsmn_strcpy(const char *path[], const char *json,
> +JSMN_API char *jsmn_strdup(const char *path[], const char *json,
>  			   const jsmntok_t *tokens)
>  {
>  	const jsmntok_t *node;
> diff --git a/test/self/json.c b/test/self/json.c
> index d3088f1b7542..489671768923 100644
> --- a/test/self/json.c
> +++ b/test/self/json.c
> @@ -104,7 +104,7 @@ static void test_json(void)
>  	token = jsmn_skip_value(token);
>  	__json_expect(json, token, JP("boolean"), JSMN_PRIMITIVE, "true");
>  
> -	string = jsmn_strcpy(JP("string"), json, tokens);
> +	string = jsmn_strdup(JP("string"), json, tokens);
>  	if (WARN_ON(!string))
>  		goto out;
>  
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux