memcpy(_GRAS_header,"GRAS", 4);
_GRAS_header[4]=GRAS_PROTOCOL_VERSION;
_GRAS_header[5]=(char)GRAS_THISARCH;
+
+ gras_msg_ctx_mallocator =
+ xbt_mallocator_new(1000,
+ gras_msg_ctx_mallocator_new_f,
+ gras_msg_ctx_mallocator_free_f,
+ gras_msg_ctx_mallocator_reset_f);
}
/*
gras_msg_exit(void) {
VERB0("Exiting Msg");
xbt_set_free(&_gras_msgtype_set);
+
+ xbt_mallocator_free(gras_msg_ctx_mallocator);
}
/*
double timeout);
+/* We deploy a mallocator on the RPC contextes */
+#include "xbt/mallocator.h"
+extern xbt_mallocator_t gras_msg_ctx_mallocator;
+XBT_PUBLIC void* gras_msg_ctx_mallocator_new_f(void);
+XBT_PUBLIC void gras_msg_ctx_mallocator_free_f(void* dict);
+XBT_PUBLIC void gras_msg_ctx_mallocator_reset_f(void* dict);
+
+
#endif /* GRAS_MESSAGE_PRIVATE_H */
return res;
}
+/* Mallocator cruft */
+xbt_mallocator_t gras_msg_ctx_mallocator = NULL;
+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, sizeof(s_gras_msg_cb_ctx_t),0);
+}
+
/** @brief Launch a RPC call, but do not block for the answer */
gras_msg_cb_ctx_t
gras_msg_rpc_async_call(gras_socket_t server,
double timeOut,
gras_msgtype_t msgtype,
void *request) {
- gras_msg_cb_ctx_t ctx = xbt_new0(s_gras_msg_cb_ctx_t,1);
+ gras_msg_cb_ctx_t ctx = xbt_mallocator_get(gras_msg_ctx_mallocator);
if (msgtype->ctn_type) {
xbt_assert1(request,
RETHROW;
}
- free(ctx);
+ xbt_mallocator_release(gras_msg_ctx_mallocator, ctx);
if (received.kind == e_gras_msg_kind_rpcerror) {
xbt_ex_t e;
memcpy(&e,received.payl,received.payl_size);