Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-uggrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
staging
dune-uggrid
Commits
163745f4
Commit
163745f4
authored
17 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup: remove the old code which used the UG general heap for the environment structure
[[Imported from SVN: r8296]]
parent
9551994e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
low/initlow.c
+1
-10
1 addition, 10 deletions
low/initlow.c
low/ugenv.c
+13
-76
13 additions, 76 deletions
low/ugenv.c
low/ugenv.h
+2
-2
2 additions, 2 deletions
low/ugenv.h
with
16 additions
and
88 deletions
low/initlow.c
+
1
−
10
View file @
163745f4
...
...
@@ -88,10 +88,6 @@ INT NS_PREFIX InitLow ()
INT
err
;
char
buffer
[
BUFFSIZE
];
/* keep type for sscanf */
int
heapSize
;
/* init heaps.c */
if
((
err
=
InitHeaps
())
!=
0
)
{
...
...
@@ -100,12 +96,7 @@ INT NS_PREFIX InitLow ()
}
/* init ugenv.c */
if
(
GetDefaultValue
(
DEFAULTSFILENAME
,
"envmemory"
,
buffer
)
==
0
)
sscanf
(
buffer
,
" %d "
,
&
heapSize
);
else
heapSize
=
DEFAULTENVSIZE
;
if
((
err
=
InitUgEnv
(
heapSize
))
!=
0
)
if
((
err
=
InitUgEnv
())
!=
0
)
{
SetHiWrd
(
err
,
__LINE__
);
return
(
err
);
...
...
This diff is collapsed.
Click to expand it.
low/ugenv.c
+
13
−
76
View file @
163745f4
...
...
@@ -38,15 +38,6 @@
/** \todo this is a hierarchy conflict, remove. (VR) */
#include
"ugdevices.h"
/* If this is set, we use the normal heap provided by the operating system instead
of the built-in UG heap. That way we don't have to give an initial heap size
ever. And that in turn make the Dune UGGrid interface easier, because UGGrid
users don't even have to know what the UG environment heap is.
In fact I currently see no reason not to always use the operating system heap.
Please report problems to sander at mi dot fu-berlin dot de
*/
#define USE_OS_HEAP
USING_UG_NAMESPACE
/****************************************************************************/
...
...
@@ -67,9 +58,6 @@ USING_UG_NAMESPACE
/* */
/****************************************************************************/
#ifndef USE_OS_HEAP
static
HEAP
*
envHeap
=
NULL
;
/* heap used for the environment */
#endif
/** \brief Path to current directory
We only need the first entry to be zero-initialized. */
...
...
@@ -94,32 +82,17 @@ static char RCS_ID("$Header$",UG_RCS_STRING);
*/
/****************************************************************************/
INT
NS_PREFIX
InitUgEnv
(
INT
heapSize
)
INT
NS_PREFIX
InitUgEnv
()
{
ENVDIR
*
root
;
#ifndef USE_OS_HEAP
void
*
buffer
;
/* Environment heap already initialized? */
if
(
envHeap
)
return
0
;
/* allocate memory from system */
if
((
buffer
=
malloc
(
heapSize
))
==
NULL
)
return
(
__LINE__
);
/* initialize heap structure */
if
((
envHeap
=
NewHeap
(
GENERAL_HEAP
,
heapSize
,
buffer
))
==
NULL
)
return
(
__LINE__
);
/* allocate root directory */
if
((
root
=
(
ENVDIR
*
)
GetMem
(
envHeap
,
sizeof
(
ENVDIR
),
0
))
==
NULL
)
return
(
__LINE__
);
#else
/* Environment heap already initialized? */
if
(
path
[
0
])
return
0
;
/* allocate root directory */
if
((
root
=
(
ENVDIR
*
)
malloc
(
sizeof
(
ENVDIR
)))
==
NULL
)
return
(
__LINE__
);
#endif
root
->
type
=
ROOT_DIR
;
root
->
next
=
root
->
previous
=
root
->
down
=
NULL
;
strcpy
(
root
->
name
,
"root"
);
...
...
@@ -301,11 +274,8 @@ ENVITEM * NS_PREFIX MakeEnvItem (const char *name, const INT type, const INT siz
if
(
type
%
2
==
0
)
{
/* new variable */
#ifndef USE_OS_HEAP
newItem
=
(
ENVITEM
*
)
GetMem
(
envHeap
,
size
,
0
);
#else
newItem
=
(
ENVITEM
*
)
malloc
(
size
);
#endif
if
(
newItem
==
NULL
)
{
UserWriteF
(
"MakeEnvItem(): envHeap out of memory
\n
"
);
...
...
@@ -317,11 +287,8 @@ ENVITEM * NS_PREFIX MakeEnvItem (const char *name, const INT type, const INT siz
{
/* new directory */
if
(
pathIndex
+
1
>=
MAXENVPATH
)
return
(
NULL
);
#ifndef USE_OS_HEAP
newItem
=
(
ENVITEM
*
)
GetMem
(
envHeap
,
size
,
0
);
#else
newItem
=
(
ENVITEM
*
)
malloc
(
size
);
#endif
if
(
newItem
==
NULL
)
{
UserWriteF
(
"MakeEnvItem(): envHeap out of memory
\n
"
);
...
...
@@ -403,11 +370,7 @@ INT NS_PREFIX RemoveEnvItem (ENVITEM *theItem)
theItem
->
v
.
next
->
v
.
previous
=
theItem
->
v
.
previous
;
/* deallocate memory */
#ifndef USE_OS_HEAP
DisposeMem
(
envHeap
,
theItem
);
#else
free
(
theItem
);
#endif
/* return ok */
return
(
0
);
...
...
@@ -424,11 +387,7 @@ INT RemoveEnvDirContent (ENVITEM *theItem)
Next
=
NEXT_ENVITEM
(
Item
);
if
(
IS_ENVDIR
(
Item
))
RemoveEnvDirContent
(
ENVITEM_DOWN
(
Item
));
#ifndef USE_OS_HEAP
DisposeMem
(
envHeap
,
Item
);
#else
free
(
Item
);
#endif
}
return
(
0
);
...
...
@@ -477,11 +436,7 @@ INT NS_PREFIX RemoveEnvDir (ENVITEM *theItem)
theItem
->
v
.
next
->
v
.
previous
=
theItem
->
v
.
previous
;
/* deallocate memory */
#ifndef USE_OS_HEAP
DisposeMem
(
envHeap
,
theItem
);
#else
free
(
theItem
);
#endif
return
(
0
);
}
...
...
@@ -614,11 +569,11 @@ ENVITEM * NS_PREFIX SearchEnv (const char *name, const char *where, INT type, IN
/****************************************************************************/
/** \brief Allocate memory from environment heap
/** \brief
For backward compatibility:
Allocate memory from environment heap
* @param size - number of bytes to be allocated
This function allocates memory from environment heap.
\deprecated Simply a wrapper for malloc()
@return <ul>
Pointer to allocated memory
...
...
@@ -627,49 +582,37 @@ ENVITEM * NS_PREFIX SearchEnv (const char *name, const char *where, INT type, IN
void
*
NS_PREFIX
AllocEnvMemory
(
INT
size
)
{
#ifndef USE_OS_HEAP
return
(
GetMem
(
envHeap
,
size
,
0
));
#else
return
malloc
(
size
);
#endif
}
/****************************************************************************/
/** \brief Deallocate memory from environment heap
/** \brief
For backward compatibility:
Deallocate memory from environment heap
* @param buffer - pointer to buffer previously allocated
This function deallocates memory from environment heap.
\deprecated Simply a wrapper for free()
*/
/****************************************************************************/
void
NS_PREFIX
FreeEnvMemory
(
void
*
buffer
)
{
#ifndef USE_OS_HEAP
DisposeMem
(
envHeap
,
buffer
);
#else
free
(
buffer
);
#endif
}
/****************************************************************************/
/** \brief Print size and used of environment heap to string
/** \brief
For backward compatibility:
Print size and used of environment heap to string
* @param s - string to print on
This function prints size and used of environment heap to string.
This function used to print size and used percentage of the environment heap
to a string. Ever since the operating system heap is used this information
is not available anymore.
*/
/****************************************************************************/
void
NS_PREFIX
EnvHeapInfo
(
char
*
s
)
{
#ifndef USE_OS_HEAP
sprintf
(
s
,
" size: %ld
\n
used: %ld
\n
"
,
HeapSize
(
envHeap
),
HeapUsed
(
envHeap
));
#else
sprintf
(
s
,
" no heap information available
\n
"
);
#endif
sprintf
(
s
,
"no heap information available
\n
"
);
}
/****************************************************************************/
...
...
@@ -713,13 +656,7 @@ INT NS_PREFIX GetNewEnvVarID ()
INT
NS_PREFIX
ExitUgEnv
()
{
ENVITEM
*
Item
,
*
Next
,
*
newDown
;
#ifndef USE_OS_HEAP
free
(
envHeap
);
envHeap
=
NULL
;
#else
RemoveEnvDirContent
((
ENVITEM
*
)
path
[
0
]);
path
[
0
]
=
NULL
;
#endif
return
0
;
}
This diff is collapsed.
Click to expand it.
low/ugenv.h
+
2
−
2
View file @
163745f4
...
...
@@ -140,8 +140,8 @@ typedef union envitem ENVITEM;
/* */
/****************************************************************************/
/* initialize environment
with following heapSize
*/
INT
InitUgEnv
(
INT
heapSize
);
/* initialize environment */
INT
InitUgEnv
();
/* Free all memory allocated for the environment */
INT
ExitUgEnv
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment