public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: fhandler_fifo: reduce size Date: Mon, 9 Nov 2020 13:48:54 +0000 (GMT) [thread overview] Message-ID: <20201109134854.11458385E830@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f505e7a032665e30b6a33c68c4b8739a0fcd3a27 commit f505e7a032665e30b6a33c68c4b8739a0fcd3a27 Author: Ken Brown <kbrown@cornell.edu> Date: Sun Nov 8 12:02:39 2020 -0500 Cygwin: fhandler_fifo: reduce size Replace the 'WCHAR pipe_name_buf[48]' class member by 'PWCHAR pipe_name_buf', and allocate space for the latter as needed. Change the default constructor to accommodate this change, and add a destructor that frees the allocated space. Also change get_pipe_name and clone to accommodate this change. Diff: --- winsup/cygwin/fhandler.h | 12 +++++++----- winsup/cygwin/fhandler_fifo.cc | 11 +++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index d7bd0ac06..fe76c0781 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1384,7 +1384,7 @@ class fhandler_fifo: public fhandler_base HANDLE thr_sync_evt; /* The thread has terminated. */ UNICODE_STRING pipe_name; - WCHAR pipe_name_buf[CYGWIN_FIFO_PIPE_NAME_LEN + 1]; + PWCHAR pipe_name_buf; fifo_client_handler *fc_handler; /* Dynamically growing array. */ int shandlers; /* Size (capacity) of the array. */ int nhandlers; /* Number of elements in the array. */ @@ -1467,6 +1467,11 @@ class fhandler_fifo: public fhandler_base public: fhandler_fifo (); + ~fhandler_fifo () + { + if (pipe_name_buf) + cfree (pipe_name_buf); + } /* Called if we appear to be at EOF after polling fc_handlers. */ bool hit_eof () const { return !nwriters () && !IsEventSignalled (writer_opening); } @@ -1512,11 +1517,8 @@ public: { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_fifo)); fhandler_fifo *fhf = new (ptr) fhandler_fifo (ptr); - /* We don't want our client list to change any more. */ copyto (fhf); - /* fhf->pipe_name_buf is a *copy* of this->pipe_name_buf, but - fhf->pipe_name.Buffer == this->pipe_name_buf. */ - fhf->pipe_name.Buffer = fhf->pipe_name_buf; + fhf->pipe_name_buf = NULL; return fhf; } }; diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index 3af7e2f72..eff05d242 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -131,25 +131,28 @@ fhandler_fifo::fhandler_fifo (): fhandler_base (), read_ready (NULL), write_ready (NULL), writer_opening (NULL), owner_needed_evt (NULL), owner_found_evt (NULL), update_needed_evt (NULL), - cancel_evt (NULL), thr_sync_evt (NULL), + cancel_evt (NULL), thr_sync_evt (NULL), pipe_name_buf (NULL), fc_handler (NULL), shandlers (0), nhandlers (0), reader (false), writer (false), duplexer (false), max_atomic_write (DEFAULT_PIPEBUFSIZE), me (null_fr_id), shmem_handle (NULL), shmem (NULL), shared_fc_hdl (NULL), shared_fc_handler (NULL) { - pipe_name_buf[0] = L'\0'; need_fork_fixup (true); } PUNICODE_STRING fhandler_fifo::get_pipe_name () { - if (!pipe_name_buf[0]) + if (!pipe_name_buf) { + pipe_name.Length = CYGWIN_FIFO_PIPE_NAME_LEN * sizeof (WCHAR); + pipe_name.MaximumLength = pipe_name.Length + sizeof (WCHAR); + pipe_name_buf = (PWCHAR) cmalloc_abort (HEAP_STR, + pipe_name.MaximumLength); + pipe_name.Buffer = pipe_name_buf; __small_swprintf (pipe_name_buf, L"%S-fifo.%08x.%016X", &cygheap->installation_key, get_dev (), get_ino ()); - RtlInitUnicodeString (&pipe_name, pipe_name_buf); } return &pipe_name; }
reply other threads:[~2020-11-09 13:48 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20201109134854.11458385E830@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@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: linkBe 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).