From 07feb088392eafacab61493d532cd67f1019fa65 Mon Sep 17 00:00:00 2001 From: corinna Date: Wed, 18 Jul 2007 11:15:50 +0000 Subject: [PATCH] * cygheap.h (shared_prefix): De-const. (shared_prefix_buf): Add static buffer for shared prefix to avoid additional allocation. * cygheap.cc (cygheap_init): Set cygheap->shared_prefix to cygheap->shared_prefix_buf and strcpy. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/cygheap.cc | 4 +++- winsup/cygwin/cygheap.h | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5afa9dafd3..73e0f392a6 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2007-07-18 Corinna Vinschen + + * cygheap.h (shared_prefix): De-const. + (shared_prefix_buf): Add static buffer for shared prefix to avoid + additional allocation. + * cygheap.cc (cygheap_init): Set cygheap->shared_prefix to + cygheap->shared_prefix_buf and strcpy. + 2007-07-17 Corinna Vinschen * fhandler.cc (fhandler_base::fhaccess): Add check for R/O file system. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 2c937fc7c3..3b4b72ba7f 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -163,8 +163,10 @@ cygheap_init () if (!cygheap->sigs) sigalloc (); + /* Should this ever change, keep in mind that shared_prefix_buf is exactly + 8 bytes long, just enough to match the size of the "Global\\" string. */ if (!cygheap->shared_prefix) - cygheap->shared_prefix = cstrdup ( + strcpy (cygheap->shared_prefix = cygheap->shared_prefix_buf, wincap.has_terminal_services () ? "Global\\" : ""); } diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index 9372305544..3ac43ba2d6 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -279,7 +279,8 @@ struct init_cygheap cwdstuff cwd; dtable fdtab; LUID luid[SE_NUM_PRIVS]; - const char *shared_prefix; + char *shared_prefix; + char shared_prefix_buf[8]; #ifdef DEBUGGING cygheap_debug debug; #endif -- 2.11.0