My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
omalloc
omalloc.c
Go to the documentation of this file.
1
/*******************************************************************
2
* File: omalloc.c
3
* Purpose: implementation of ANSI-C conforming malloc functions
4
* -- the real version
5
* Author: obachman@mathematik.uni-kl.de (Olaf Bachmann)
6
* Created: 11/99
7
*******************************************************************/
8
9
#include <stdlib.h>
10
#include <stdio.h>
11
12
#ifndef OMALLOC_C
13
#define OMALLOC_C
14
15
#include "
omalloc.h
"
16
17
#ifdef OM_MALLOC_MARK_AS_STATIC
18
#define OM_MARK_AS_STATIC(addr) omMarkAsStaticAddr(addr)
19
#else
20
#define OM_MARK_AS_STATIC(addr) do {} while (0)
21
#endif
22
23
#if OM_PROVIDE_MALLOC > 0
24
25
void
*
calloc
(
size_t
nmemb,
size_t
size
)
26
{
27
void
* addr;
28
if
(
size
== 0)
size
= 1;
29
if
(nmemb == 0) nmemb = 1;
30
31
size
=
size
*nmemb;
32
omTypeAlloc0Aligned
(
void
*, addr,
size
);
33
OM_MARK_AS_STATIC
(addr);
34
return
addr;
35
}
36
37
void
free
(
void
* addr)
38
{
39
omfree
(addr);
40
}
41
42
void
*
valloc
(
size_t
size
)
43
{
44
fputs(
"omalloc Warning: valloc not yet implemented\n"
,stderr);
45
fflush(
NULL
);
46
return
NULL
;
47
}
48
49
void
*
realloc
(
void
* old_addr,
size_t
new_size)
50
{
51
if
(old_addr && new_size)
52
{
53
void
* new_addr;
54
omTypeReallocAligned
(old_addr,
void
*, new_addr, new_size);
55
OM_MARK_AS_STATIC
(new_addr);
56
return
new_addr;
57
}
58
else
59
{
60
free
(old_addr);
61
return
malloc
(new_size);
62
}
63
}
64
65
/* on some systems strdup is a macro -- replace it unless OMALLOC_FUNC
66
is defined */
67
#ifndef OMALLOC_USES_MALLOC
68
#if !defined(OMALLOC_FUNC)
69
#undef strdup
70
#endif
71
char
*
strdup_
(
const
char
* addr)
72
{
73
char
* n_s;
74
if
(addr)
75
{
76
n_s =
omStrDup
(addr);
77
OM_MARK_AS_STATIC
(n_s);
78
return
n_s;
79
}
80
return
NULL
;
81
}
82
#endif
83
#endif
84
85
void
*
malloc
(
size_t
size
)
86
{
87
void
* addr;
88
if
(
size
== 0)
size
= 1;
89
90
omTypeAllocAligned
(
void
*, addr,
size
);
91
OM_MARK_AS_STATIC
(addr);
92
return
addr;
93
}
94
95
void
freeSize
(
void
* addr,
size_t
size
)
96
{
97
if
(addr)
omFreeSize
(addr,
size
);
98
}
99
100
void
*
reallocSize
(
void
* old_addr,
size_t
old_size,
size_t
new_size)
101
{
102
if
(old_addr && new_size)
103
{
104
void
* new_addr;
105
omTypeReallocAlignedSize
(old_addr, old_size,
void
*, new_addr, new_size);
106
OM_MARK_AS_STATIC
(new_addr);
107
return
new_addr;
108
}
109
else
110
{
111
freeSize
(old_addr, old_size);
112
return
malloc
(new_size);
113
}
114
}
115
#endif
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition
cf_ops.cc:600
strdup_
#define strdup_
Definition
mmstd.c:29
omStrDup
#define omStrDup(s)
Definition
omAllocDecl.h:263
omfree
#define omfree(addr)
Definition
omAllocDecl.h:237
omTypeReallocAlignedSize
#define omTypeReallocAlignedSize
Definition
omAllocDecl.h:276
omFreeSize
#define omFreeSize(addr, size)
Definition
omAllocDecl.h:260
omTypeAlloc0Aligned
#define omTypeAlloc0Aligned
Definition
omAllocDecl.h:272
omTypeReallocAligned
#define omTypeReallocAligned
Definition
omAllocDecl.h:281
omTypeAllocAligned
#define omTypeAllocAligned
Definition
omAllocDecl.h:271
realloc
#define realloc
Definition
omAllocFunc.c:16
freeSize
#define freeSize
Definition
omAllocFunc.c:15
valloc
#define valloc
Definition
omAllocFunc.c:19
free
#define free
Definition
omAllocFunc.c:14
calloc
#define calloc
Definition
omAllocFunc.c:13
malloc
#define malloc
Definition
omAllocFunc.c:12
reallocSize
#define reallocSize
Definition
omAllocFunc.c:17
NULL
#define NULL
Definition
omList.c:12
OM_MARK_AS_STATIC
#define OM_MARK_AS_STATIC(addr)
Definition
omalloc.c:20
omalloc.h
Generated on
for My Project by
doxygen 1.17.0
for
Singular