public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Nick Stoughton <nstoughton@logitech.com>
To: libc-help@sourceware.org
Subject: fmemopen question
Date: Thu, 12 Oct 2023 07:57:16 -0700	[thread overview]
Message-ID: <CACpbN916YAqDMVhszqNLO_D_STeg65NPLU3OWBn_xnXdd7w+9Q@mail.gmail.com> (raw)

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

If I open a file for writing and immediately close it:

  fclose(fopen("foo", "w"));

the file "foo" will be truncated to zero length if it exists.

However, I I do this with a memory buffer, e.g.
    char arr[] = { 'a','a','a','a','a','a','a','a','a','a', 0};
    fclose(fmemopen(arr, 10, "w"));
I would expect that arr[0] would have a null byte.

But it doesn't. Is this a bug?

-- 
Nick

             reply	other threads:[~2023-10-12 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 14:57 Nick Stoughton [this message]
2023-10-16 21:34 ` Adhemerval Zanella Netto

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=CACpbN916YAqDMVhszqNLO_D_STeg65NPLU3OWBn_xnXdd7w+9Q@mail.gmail.com \
    --to=nstoughton@logitech.com \
    --cc=libc-help@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).