From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8300 invoked by alias); 21 Jun 2013 17:25:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8193 invoked by uid 89); 21 Jun 2013 17:25:15 -0000 X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 21 Jun 2013 17:25:15 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5LHPDnR005379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Jun 2013 13:25:14 -0400 Received: from barimba.redhat.com (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5LHPBSt021447; Fri, 21 Jun 2013 13:25:13 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 03/16] Add new_remote_state Date: Fri, 21 Jun 2013 17:25:00 -0000 Message-Id: <1371835506-15691-4-git-send-email-tromey@redhat.com> In-Reply-To: <1371835506-15691-1-git-send-email-tromey@redhat.com> References: <1371835506-15691-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-06/txt/msg00602.txt.bz2 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/remote.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index 054fd39..7aa20f3 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -395,12 +395,26 @@ 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); + + result->buf_size = 400; + result->buf = xmalloc (result->buf_size); + + return result; } /* Description of the remote protocol for a given architecture. */ @@ -11797,9 +11811,7 @@ _initialize_remote (void) 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); + remote_state = new_remote_state (); init_remote_ops (); add_target (&remote_ops); -- 1.8.1.4