Add new_remote_state
authorTom Tromey <tromey@redhat.com>
Wed, 14 Aug 2013 18:00:34 +0000 (18:00 +0000)
committerTom Tromey <tromey@redhat.com>
Wed, 14 Aug 2013 18:00:34 +0000 (18:00 +0000)
Add new_remote_state and change remote_state to be a pointer.  This is
a preparatory patch for a later series.  It could perhaps be omitted,
but new_remote_state also does some initialization that was previously
done for the globals.

* remote.c (remote_state): Now a pointer.
(get_remote_state_raw): Update.
(new_remote_state): New function.
(_initialize_remote): Use new_remote_state.

gdb/ChangeLog
gdb/remote.c

index c3c28d5e56e627cb11a30274b4b473ee082ec055..856652c667ec9eb7f69ab07120f556ec97b2e460 100644 (file)
@@ -1,3 +1,10 @@
+2013-08-14  Tom Tromey  <tromey@redhat.com>
+
+       * remote.c (remote_state): Now a pointer.
+       (get_remote_state_raw): Update.
+       (new_remote_state): New function.
+       (_initialize_remote): Use new_remote_state.
+
 2013-08-14  Tom Tromey  <tromey@redhat.com>
 
        * remote.c (remote_protocol_features): Now const.
index 9d9aae48837fd6b63fedb247af5de5e7fd6d5082..f45baa0481c48716a480112706381e3abe24d7bd 100644 (file)
@@ -390,12 +390,28 @@ remote_multi_process_p (struct remote_state *rs)
    have access to the current target when we need it, so for now it is
    static.  This will be fine for as long as only one target is in use
    at a time.  */
-static struct remote_state remote_state;
+static struct remote_state *remote_state;
 
 static struct remote_state *
 get_remote_state_raw (void)
 {
-  return &remote_state;
+  return remote_state;
+}
+
+/* Allocate a new struct remote_state with xmalloc, initialize it, and
+   return it.  */
+
+static struct remote_state *
+new_remote_state (void)
+{
+  struct remote_state *result = XCNEW (struct remote_state);
+
+  /* The default buffer size is unimportant; it will be expanded
+     whenever a larger buffer is needed. */
+  result->buf_size = 400;
+  result->buf = xmalloc (result->buf_size);
+
+  return result;
 }
 
 /* Description of the remote protocol for a given architecture.  */
@@ -11793,11 +11809,8 @@ _initialize_remote (void)
 
   /* Initialize the per-target state.  At the moment there is only one
      of these, not one per target.  Only one target is active at a
-     time.  The default buffer size is unimportant; it will be expanded
-     whenever a larger buffer is needed.  */
-  rs = get_remote_state_raw ();
-  rs->buf_size = 400;
-  rs->buf = xmalloc (rs->buf_size);
+     time.  */
+  remote_state = new_remote_state ();
 
   init_remote_ops ();
   add_target (&remote_ops);
This page took 0.049161 seconds and 4 git commands to generate.