From: Jim Blandy <jimb@codesourcery.com>
To: Vladimir Prus <vladimir@codesourcery.com>
Cc: Daniel Jacobowitz <drow@false.org>,
Mark Kettenis <mark.kettenis@xs4all.nl>,
gdb-patches@sources.redhat.com
Subject: Re: [PATCH] zero-terminate result of target_read_alloc
Date: Tue, 18 Jul 2006 19:51:00 -0000 [thread overview]
Message-ID: <vt2fygy8zez.fsf@theseus.home.> (raw)
In-Reply-To: <200607181751.06219.vladimir@codesourcery.com> (Vladimir Prus's message of "Tue, 18 Jul 2006 17:51:04 +0400")
Vladimir Prus <vladimir@codesourcery.com> writes:
> If target_read_alloc does not zero-terminate data, it requires
> either manually zero-terminating result, or drag length
> everywhere. And while it's possible for a remote side to include
> extra zero byte and increase the size of data by one, that's a
> fairly uncommon interface, and is likely to result in buggy stubs.
Another way to look at it is to say that target_read_alloc clearly
operates on blocks of uninterpreted bytes --- it returns address and
length, after all --- but the interface as given requires users
retrieving text that they'd like to process as null-terminated strings
to make an extra copy. The change to the interface Vlad's proposed
would make the copy unnecessary.
Of course we can't accomodate every random string representation
anyone could come up with; we can't avoid copies in every case. And
it's not our job to do so. But null-termination is a common need, and
one actually at hand.
Examples from elsewhere: in Guile, even though our strings could
contain arbitrary binary data, we also included an extra null byte at
the end, beyond the official length of the string, so that C code that
knew it was working with text (filenames, for example) could simply
use the string contents in place, without needing to make a
null-terminated copy.
next prev parent reply other threads:[~2006-07-18 19:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 9:56 Vladimir Prus
2006-07-18 11:25 ` Mark Kettenis
2006-07-18 11:33 ` Vladimir Prus
2006-07-18 12:34 ` Daniel Jacobowitz
2006-07-18 13:15 ` Mark Kettenis
2006-07-18 13:39 ` Daniel Jacobowitz
2006-07-18 13:51 ` Vladimir Prus
2006-07-18 19:51 ` Jim Blandy [this message]
2006-07-24 4:09 ` Daniel Jacobowitz
2006-07-24 21:41 ` Mark Kettenis
2006-07-24 22:00 ` Daniel Jacobowitz
2006-07-26 21:53 ` Mark Kettenis
2006-07-26 22:25 ` Daniel Jacobowitz
2006-07-26 22:36 ` Mark Kettenis
2006-07-27 21:25 ` Daniel Jacobowitz
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=vt2fygy8zez.fsf@theseus.home. \
--to=jimb@codesourcery.com \
--cc=drow@false.org \
--cc=gdb-patches@sources.redhat.com \
--cc=mark.kettenis@xs4all.nl \
--cc=vladimir@codesourcery.com \
/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