devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Ayush Singh <ayush@beagleboard.org>
Cc: Andreas Gnau <andreas.gnau@iopsys.eu>,
	d-gole@ti.com, lorforlinux@beagleboard.org,
	jkridner@beagleboard.org, robertcnelson@beagleboard.org,
	Andrew Davis <afd@ti.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Simon Glass <sjg@chromium.org>,
	devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH v2 2/4] srcpos: Define srcpos_free
Date: Wed, 28 May 2025 15:16:08 +1000	[thread overview]
Message-ID: <aDacGNbvxcxI8SrS@zatzit> (raw)
In-Reply-To: <20250311-previous-value-v2-2-e4a8611e956f@beagleboard.org>

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]

On Tue, Mar 11, 2025 at 09:05:38PM +0530, Ayush Singh wrote:
> srcpos can be chained together using srcpos_extend. However, in such
> cases, we need to free all the chained nodes.
> 
> srcpos_free is a helper to recursively free all the linked srcpos.
> 
> Signed-off-by: Ayush Singh <ayush@beagleboard.org>

This should also _use_ the new function in any existing places it make
sense.  On a quick glance I can only see one such place, in
merge_nodes() where we use a plain free() on the srcpos info of an
overwritten property.

> ---
>  srcpos.c | 11 +++++++++++
>  srcpos.h |  1 +
>  2 files changed, 12 insertions(+)
> 
> diff --git a/srcpos.c b/srcpos.c
> index 5e2f7dd299184ff86b00b280dc31498cb9830e28..5bb57bf6856c6ff6b8eb993aff5d216c63bf5ecb 100644
> --- a/srcpos.c
> +++ b/srcpos.c
> @@ -287,6 +287,17 @@ struct srcpos *srcpos_extend(struct srcpos *pos, struct srcpos *newtail)
>  	return pos;
>  }
>  
> +void srcpos_free(struct srcpos *pos)
> +{
> +	struct srcpos *p_next;
> +
> +	while (pos) {
> +		p_next = pos->next;
> +		free(pos);
> +		pos = p_next;
> +	}
> +}
> +
>  char *
>  srcpos_string(struct srcpos *pos)
>  {
> diff --git a/srcpos.h b/srcpos.h
> index 4318d7ad34d91d2ada1a5d7f92d2c84148fec366..4d60b50e31197c2da6a7fa8851c5e5a6717d78a6 100644
> --- a/srcpos.h
> +++ b/srcpos.h
> @@ -88,6 +88,7 @@ extern void srcpos_update(struct srcpos *pos, const char *text, int len);
>  extern struct srcpos *srcpos_copy(struct srcpos *pos);
>  extern struct srcpos *srcpos_extend(struct srcpos *new_srcpos,
>  				    struct srcpos *old_srcpos);
> +extern void srcpos_free(struct srcpos *pos);
>  extern char *srcpos_string(struct srcpos *pos);
>  extern char *srcpos_string_first(struct srcpos *pos, int level);
>  extern char *srcpos_string_last(struct srcpos *pos, int level);
> 

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-05-28  5:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 15:35 [PATCH v2 0/4] Add capability to create property from old property Ayush Singh
2025-03-11 15:35 ` [PATCH v2 1/4] Add alloc_marker Ayush Singh
2025-05-28  5:13   ` David Gibson
2025-03-11 15:35 ` [PATCH v2 2/4] srcpos: Define srcpos_free Ayush Singh
2025-05-28  5:16   ` David Gibson [this message]
2025-03-11 15:35 ` [PATCH v2 3/4] dtc: Add /./ Ayush Singh
2025-03-11 15:49   ` Andreas Gnau
2025-06-02  8:20   ` David Gibson
2025-03-11 15:35 ` [PATCH v2 4/4] tests: Add test for /./ Ayush Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aDacGNbvxcxI8SrS@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=afd@ti.com \
    --cc=andreas.gnau@iopsys.eu \
    --cc=ayush@beagleboard.org \
    --cc=d-gole@ti.com \
    --cc=devicetree-compiler@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=jkridner@beagleboard.org \
    --cc=lorforlinux@beagleboard.org \
    --cc=robertcnelson@beagleboard.org \
    --cc=sjg@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).