linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Buchan <M.J.Buchan@gre.ac.uk>
To: Glynn Clements <glynn.clements@virgin.net>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Returning pointer to array of structures
Date: Tue, 29 Apr 2003 11:28:39 +0100	[thread overview]
Message-ID: <20030429102839.GC22282@gre.ac.uk> (raw)
In-Reply-To: <16046.17978.731081.8548@cerise.nosuchdomain.co.uk>

On Tue, Apr 29, 2003 at 10:30:34AM +0100, Glynn Clements wrote:
> 
> OTOH, this is almost certainly an error:
> 
> 	 uri = xmlGetProp(cur, "name");
> 	 xmlFree(uri);
> 	 mePtr[i].appsubmenu = uri;
> 
> Assuming that xmlFree() is a "destructor", you shouldn't be calling it
> until you have actually finished with "uri". Given that you are
> storing "uri" for later use, you probably either shouldn't be calling
> xmlFree() at all, or you should be copying the string itself (e.g. 
> with strdup()), and not just the pointer.

Thanks! This was the error. I have used strdup() as you sugessted and
now it all seems to be working. My structure is returned to main()
successfully and i can print out each element using a for loop.

Thanks again for your help.

Martin

  reply	other threads:[~2003-04-29 10:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-29  8:31 Returning pointer to array of structures Martin Buchan
2003-04-28 10:57 ` Rafael Santos
2003-04-30  8:24   ` Martin Buchan
2003-05-01  0:49     ` Glynn Clements
2003-05-01  6:03       ` Rafael Santos
2003-05-01  9:49       ` Martin Buchan
2003-04-29  9:30 ` Glynn Clements
2003-04-29 10:28   ` Martin Buchan [this message]
2003-04-29 12:11 ` Jason Cooper
2003-04-29 20:57   ` Glynn Clements

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=20030429102839.GC22282@gre.ac.uk \
    --to=m.j.buchan@gre.ac.uk \
    --cc=glynn.clements@virgin.net \
    --cc=linux-c-programming@vger.kernel.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).