Re: [PATCH v2 1/4] Add alloc_marker

David Gibson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <aDabZokq7CMAUNaa@zatzit>
On Tue, Mar 11, 2025 at 09:05:37PM +0530, Ayush Singh wrote:
> - Add helper to allocate new marker
> 
> Reviewed-by: David Gibson <[email protected]>
> Signed-off-by: Ayush Singh <[email protected]>

This is a reasonable cleanup regardless of anything else.  Applied.

> ---
>  data.c | 20 +++++++++++++++-----
>  dtc.h  |  2 ++
>  2 files changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/data.c b/data.c
> index 14734233ad8b7ebd38c3e62442b81aae66601806..913796f2e664d07cdc48e0cbf2ab5d6fe9978072 100644
> --- a/data.c
> +++ b/data.c
> @@ -228,11 +228,7 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref)
>  {
>  	struct marker *m;
>  
> -	m = xmalloc(sizeof(*m));
> -	m->offset = d.len;
> -	m->type = type;
> -	m->ref = ref;
> -	m->next = NULL;
> +	m = alloc_marker(d.len, type, ref);
>  
>  	return data_append_markers(d, m);
>  }
> @@ -254,3 +250,17 @@ bool data_is_one_string(struct data d)
>  
>  	return true;
>  }
> +
> +struct marker *alloc_marker(unsigned int offset, enum markertype type,
> +			    char *ref)
> +{
> +	struct marker *m;
> +
> +	m = xmalloc(sizeof(*m));
> +	m->offset = offset;
> +	m->type = type;
> +	m->ref = ref;
> +	m->next = NULL;
> +
> +	return m;
> +}
> diff --git a/dtc.h b/dtc.h
> index 4c4aaca1fc417c9d93e904e64b2c40216ee1b093..86928e1eea9764fe5d74d6dbb987589d65d54b66 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -183,6 +183,8 @@ struct data data_append_byte(struct data d, uint8_t byte);
>  struct data data_append_zeroes(struct data d, int len);
>  struct data data_append_align(struct data d, int align);
>  
> +struct marker *alloc_marker(unsigned int offset, enum markertype type,
> +			    char *ref);
>  struct data data_add_marker(struct data d, enum markertype type, char *ref);
>  
>  bool data_is_one_string(struct data d);
> 

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmg2m2UACgkQzQJF27ox
2Gfdfg/+JkJQT8x13niCy0ykx8Fmh7fef2U2Wd5t40kfjYLPKd4EP/JKUB861Mwv
vQlRMXC/g+hqklFNf3rNHslV+ygvdcF/7Iceyt0Fk25aYUQQpuVeiZtc3TcHNq29
wEWC6Py1zx5vZ0JP70owoKs7elV4xOKMI9RRHml52o8PTPMs7gWl6EQnZ9r8RNha
ej1RCqTC/fSvRe4JidZgXaqVnn7M18MBYvvEFGBNbJ4dABb1ZsVVoz9JO6YTcY8p
NTTMgn6GzX3czqUwYpJtFq29352XGCjg2mD5YAf8whTPo/7+Yvb/1AiNNbwqolUQ
IRkUQZ9LHGwMiaWQnmbDolFOaxBfnRLgXVpFSk0kRuAh+nLkj3HuxZFaij7Jxl8K
MOPKzY1yFEKCTdG/0SLpg5Fe8n3wJYDX08yRWBgnPvJ3m57O8DD+oXSxsvozNQcG
/KIds2Veb/1DXFhCdeykxBDzf4d4jhMFczb1SmoOubttFf6nzoAFzYKQO6bKBNfX
2Hlg5RqPRs17lUY41AOB2U6PAtENBMDZYwcOJdhRDfBX6bhnq9V1+F+44EeFMsuB
do0GcicZvCDTEnAJDqKDCtW//ossMHuc+n9eWbqWtbhKzCi8vuOvC3w9w4sEPQRP
BY24pzF0MBZtJpejjVEsKVEroPVaVrvegki23SRfDSS36c5Xhuc=
=CogS
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.