source: CIVL/examples/mpi-omp/AMG2013/utilities/memory_dmalloc.c@ beab7f2

main test-branch
Last change on this file since beab7f2 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13
14/******************************************************************************
15 *
16 * Memory management utilities
17 *
18 * Routines to use "Debug Malloc Library", dmalloc
19 *
20 *****************************************************************************/
21
22#ifdef HYPRE_MEMORY_DMALLOC
23
24#include "hypre_memory.h"
25#include <dmalloc.h>
26
27char dmalloc_logpath_memory[256];
28
29/*--------------------------------------------------------------------------
30 * hypre_InitMemoryDebugDML
31 *--------------------------------------------------------------------------*/
32
33int
34hypre_InitMemoryDebugDML( int id )
35{
36 int *iptr;
37
38 /* do this to get the Debug Malloc Library started/initialized */
39 iptr = hypre_TAlloc(int, 1);
40 hypre_TFree(iptr);
41
42 dmalloc_logpath = dmalloc_logpath_memory;
43 sprintf(dmalloc_logpath, "dmalloc.log.%04d", id);
44
45 return 0;
46}
47
48/*--------------------------------------------------------------------------
49 * hypre_FinalizeMemoryDebugDML
50 *--------------------------------------------------------------------------*/
51
52int
53hypre_FinalizeMemoryDebugDML( )
54{
55 dmalloc_verify(NULL);
56
57 return 0;
58}
59
60/*--------------------------------------------------------------------------
61 * hypre_MAllocDML
62 *--------------------------------------------------------------------------*/
63
64char *
65hypre_MAllocDML( int size,
66 char *file,
67 int line )
68{
69 char *ptr;
70
71 if (size > 0)
72 ptr = _malloc_leap(file, line, size);
73 else
74 ptr = NULL;
75
76 return ptr;
77}
78
79/*--------------------------------------------------------------------------
80 * hypre_CAllocDML
81 *--------------------------------------------------------------------------*/
82
83char *
84hypre_CAllocDML( int count,
85 int elt_size,
86 char *file,
87 int line )
88{
89 char *ptr;
90 int size = count*elt_size;
91
92 if (size > 0)
93 {
94 ptr = _calloc_leap(file, line, count, elt_size);
95 }
96 else
97 {
98 ptr = NULL;
99 }
100
101 return ptr;
102}
103
104/*--------------------------------------------------------------------------
105 * hypre_ReAllocDML
106 *--------------------------------------------------------------------------*/
107
108char *
109hypre_ReAllocDML( char *ptr,
110 int size,
111 char *file,
112 int line )
113{
114 ptr = _realloc_leap(file, line, ptr, size);
115
116 return ptr;
117}
118
119/*--------------------------------------------------------------------------
120 * hypre_FreeDML
121 *--------------------------------------------------------------------------*/
122
123void
124hypre_FreeDML( char *ptr,
125 char *file,
126 int line )
127{
128 if (ptr)
129 {
130 _free_leap(file, line, ptr);
131 }
132}
133
134#else
135
136/* this is used only to eliminate compiler warnings */
137int hypre_empty1;
138
139#endif
Note: See TracBrowser for help on using the repository browser.