From patchwork Fri Apr 11 16:58:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Weisbach X-Patchwork-Id: 3971281 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 360C3BFF02 for ; Fri, 11 Apr 2014 16:58:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76C4520458 for ; Fri, 11 Apr 2014 16:58:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A136E20457 for ; Fri, 11 Apr 2014 16:58:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422794AbaDKQ6N (ORCPT ); Fri, 11 Apr 2014 12:58:13 -0400 Received: from mout.gmx.net ([212.227.17.22]:56417 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422754AbaDKQ6J (ORCPT ); Fri, 11 Apr 2014 12:58:09 -0400 Received: from os-dhcp008.inf.tu-dresden.de ([141.76.49.8]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MQRZw-1WOqce2tdk-00ThIM for ; Fri, 11 Apr 2014 18:58:08 +0200 From: Hannes Weisbach Reply-To: Hannes Weisbach , linux-rdma@vger.kernel.org Subject: [PATCH] Clean index map on exit Date: Fri, 11 Apr 2014 18:58:10 +0200 Message-Id: To: linux-rdma@vger.kernel.org Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) X-Mailer: Apple Mail (2.1874) X-Provags-ID: V03:K0:nh8DsoduWDmy0e/B0JvIVK6mudw+S24iFSaV/I5brSAwws7mm9b WxoUtG5Yq9kyFtuEU6PD1+f/LeFoHXOus0ng2uM888iH6rcl2PexwCahj/wFfz7KOna/Myj JRSBje/nlWnls90UH+Jiv7lCdKIMKoMcbtBYYjXcwafBh3o68Om6vvXDA861ZUNi4aDwf6G 2ywBYC3OtAXZOkImqIEuA== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the function idm_free() to free all entries of an index map. A call to this function is added in the ucma_cleanup destructor. The ucma_idm struct index_map is cleaned. Signed-off-by: Hannes Weisbach --- src/cma.c | 1 + src/indexer.c | 8 ++++++++ src/indexer.h | 1 + 3 files changed, 10 insertions(+) diff --git a/src/cma.c b/src/cma.c index 0cf4203..a533bf9 100644 --- a/src/cma.c +++ b/src/cma.c @@ -139,6 +139,7 @@ static void ucma_cleanup(void) ibv_close_device(cma_dev_array[cma_dev_cnt].verbs); } + idm_free(&ucma_idm); fastlock_destroy(&idm_lock); free(cma_dev_array); cma_dev_cnt = 0; diff --git a/src/indexer.c b/src/indexer.c index c8e8bce..4d1fd77 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -164,3 +164,11 @@ void *idm_clear(struct index_map *idm, int index) entry[idx_entry_index(index)] = NULL; return item; } + +void idm_free(struct index_map *idm) +{ + size_t i; + for (i = 0; i < IDX_ARRAY_SIZE; i++) { + free(idm->array[i]); + } +} diff --git a/src/indexer.h b/src/indexer.h index 0c5f388..829d46b 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -89,6 +89,7 @@ struct index_map int idm_set(struct index_map *idm, int index, void *item); void *idm_clear(struct index_map *idm, int index); +void idm_free(struct index_map *idm); static inline void *idm_at(struct index_map *idm, int index) {