From 4fddca5a25e18bdf8b5eb0542e0fa98203e091da Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 28 Nov 2011 13:21:41 +0100 Subject: [PATCH] Remove useless internal functions. --- src/gras/Msg/msg_private.h | 2 +- src/gras/Msg/rpc.c | 5 ----- src/simdag/private.h | 2 +- src/simdag/sd_link.c | 9 --------- src/surf/maxmin.c | 7 +------ src/surf/surf_action.c | 6 +----- src/xbt/dict.c | 16 ++-------------- src/xbt/dict_elm.c | 10 ---------- src/xbt/dict_private.h | 4 ++-- src/xbt/fifo.c | 7 +------ 10 files changed, 9 insertions(+), 59 deletions(-) diff --git a/src/gras/Msg/msg_private.h b/src/gras/Msg/msg_private.h index b760e08724..a124213e86 100644 --- a/src/gras/Msg/msg_private.h +++ b/src/gras/Msg/msg_private.h @@ -130,7 +130,7 @@ gras_msg_cb_ctx_t gras_msg_cb_ctx_new(gras_socket_t expe, #include "xbt/mallocator.h" extern xbt_mallocator_t gras_msg_ctx_mallocator; void *gras_msg_ctx_mallocator_new_f(void); -void gras_msg_ctx_mallocator_free_f(void *dict); +#define gras_msg_ctx_mallocator_free_f xbt_free_f void gras_msg_ctx_mallocator_reset_f(void *dict); diff --git a/src/gras/Msg/rpc.c b/src/gras/Msg/rpc.c index 8c7e72c6a6..c84c60531c 100644 --- a/src/gras/Msg/rpc.c +++ b/src/gras/Msg/rpc.c @@ -104,11 +104,6 @@ void *gras_msg_ctx_mallocator_new_f(void) return xbt_new0(s_gras_msg_cb_ctx_t, 1); } -void gras_msg_ctx_mallocator_free_f(void *ctx) -{ - xbt_free(ctx); -} - void gras_msg_ctx_mallocator_reset_f(void *ctx) { memset(ctx, 0, sizeof(s_gras_msg_cb_ctx_t)); diff --git a/src/simdag/private.h b/src/simdag/private.h index 7b55cfa84f..61ba759bbb 100644 --- a/src/simdag/private.h +++ b/src/simdag/private.h @@ -117,7 +117,7 @@ XBT_PUBLIC(xbt_swag_t) SD_simulate_swag(double how_long); /* could be public, bu SD_link_t __SD_link_create(void *surf_link, void *data); -void __SD_link_destroy(void *link); +#define __SD_link_destroy xbt_free_f SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data); diff --git a/src/simdag/sd_link.c b/src/simdag/sd_link.c index 2cf0faa24e..b9b83bb82d 100644 --- a/src/simdag/sd_link.c +++ b/src/simdag/sd_link.c @@ -146,12 +146,3 @@ e_SD_link_sharing_policy_t SD_link_get_sharing_policy(SD_link_t link) { return link->sharing_policy; } - - -/* Destroys a link. - */ -void __SD_link_destroy(void *link) -{ - /* link->surf_link is freed by surf_exit and link->data is freed by the user */ - xbt_free(link); -} diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index dc331ad1a4..b75e448309 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -19,7 +19,7 @@ double sg_maxmin_precision = 0.00001; static void *lmm_variable_mallocator_new_f(void); static void lmm_variable_mallocator_free_f(void *var); -static void lmm_variable_mallocator_reset_f(void *var); +#define lmm_variable_mallocator_reset_f ((void_f_pvoid_t)NULL) static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst); static void lmm_remove_all_modified_set(lmm_system_t sys); @@ -173,11 +173,6 @@ static void lmm_variable_mallocator_free_f(void *var) xbt_free(var); } -static void lmm_variable_mallocator_reset_f(void *var) -{ - /* lmm_variable_new() initializes everything */ -} - lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id, double weight, double bound, int number_of_constraints) diff --git a/src/surf/surf_action.c b/src/surf/surf_action.c index ea4317b26b..49a22ff084 100644 --- a/src/surf/surf_action.c +++ b/src/surf/surf_action.c @@ -27,7 +27,7 @@ const char *surf_action_state_names[6] = { static xbt_mallocator_t action_mallocator = NULL; static int action_mallocator_allocated_size = 0; static void* surf_action_mallocator_new_f(void); -static void surf_action_mallocator_free_f(void* action); +#define surf_action_mallocator_free_f xbt_free_f static void surf_action_mallocator_reset_f(void* action); /** @@ -55,10 +55,6 @@ static void* surf_action_mallocator_new_f(void) { return xbt_malloc(action_mallocator_allocated_size); } -static void surf_action_mallocator_free_f(void* action) { - xbt_free(action); -} - static void surf_action_mallocator_reset_f(void* action) { memset(action, 0, action_mallocator_allocated_size); } diff --git a/src/xbt/dict.c b/src/xbt/dict.c index c054fb5499..b0a5031b97 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -23,8 +23,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict, xbt, static xbt_mallocator_t dict_mallocator = NULL; static void *dict_mallocator_new_f(void); -static void dict_mallocator_free_f(void *dict); -static void dict_mallocator_reset_f(void *dict); +#define dict_mallocator_free_f xbt_free_f +#define dict_mallocator_reset_f ((void_f_pvoid_t)NULL) /*####[ Code ]###############################################################*/ @@ -816,18 +816,6 @@ static void *dict_mallocator_new_f(void) return xbt_new(s_xbt_dict_t, 1); } -static void dict_mallocator_free_f(void *dict) -{ - xbt_free(dict); -} - -static void dict_mallocator_reset_f(void *dict) -{ - /* nothing to do because all fields are - * initialized in xbt_dict_new - */ -} - #ifdef SIMGRID_TEST #include "xbt.h" #include "xbt/ex.h" diff --git a/src/xbt/dict_elm.c b/src/xbt/dict_elm.c index 4129989c27..0591621117 100644 --- a/src/xbt/dict_elm.c +++ b/src/xbt/dict_elm.c @@ -81,13 +81,3 @@ void *dict_elm_mallocator_new_f(void) { return xbt_new(s_xbt_dictelm_t, 1); } - -void dict_elm_mallocator_free_f(void *elem) -{ - xbt_free(elem); -} - -void dict_elm_mallocator_reset_f(void *elem) -{ - -} diff --git a/src/xbt/dict_private.h b/src/xbt/dict_private.h index c1b6402a69..7bf451479d 100644 --- a/src/xbt/dict_private.h +++ b/src/xbt/dict_private.h @@ -44,8 +44,8 @@ typedef struct xbt_dict_cursor_ s_xbt_dict_cursor_t; extern xbt_mallocator_t dict_elm_mallocator; extern void *dict_elm_mallocator_new_f(void); -extern void dict_elm_mallocator_free_f(void *elem); -extern void dict_elm_mallocator_reset_f(void *elem); +#define dict_elm_mallocator_free_f xbt_free_f +#define dict_elm_mallocator_reset_f ((void_f_pvoid_t)NULL) /*####[ Function prototypes ]################################################*/ xbt_dictelm_t xbt_dictelm_new(const char *key, int key_len, diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index 89ab25fa12..57e0912f26 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_fifo, xbt, "FIFO"); static void *fifo_item_mallocator_new_f(void); -static void fifo_item_mallocator_free_f(void *item); +#define fifo_item_mallocator_free_f xbt_free_f static void fifo_item_mallocator_reset_f(void *item); static xbt_mallocator_t item_mallocator = NULL; @@ -375,11 +375,6 @@ static void *fifo_item_mallocator_new_f(void) return xbt_new(s_xbt_fifo_item_t, 1); } -static void fifo_item_mallocator_free_f(void *item) -{ - xbt_free(item); -} - static void fifo_item_mallocator_reset_f(void *item) { /* memset to zero like calloc */ -- 2.20.1