Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
c6f33d8e
Commit
c6f33d8e
authored
Dec 02, 2004
by
Michael Beck
Browse files
fixed config.h include
cleaned up unused debugging code [r4552]
parent
7678991c
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/adt/xmalloc.c
View file @
c6f33d8e
...
...
@@ -14,32 +14,38 @@
[reimplement xstrdup, ... ] */
#ifdef HAVE_CONFIG_H
# include
<
config.h
>
# include
"
config.h
"
#endif
#include <stdlib.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <stdlib.h>
#include "xmalloc.h"
#include "panic.h"
void
*
(
xmalloc
)
(
size_t
size
)
{
xmalloc
(
size_t
size
)
{
void
*
res
=
malloc
(
size
);
if
(
!
res
)
xnomem
();
if
(
!
res
)
xnomem
();
memset
(
res
,
0x00
,
size
);
memset
(
res
,
0x00
,
size
);
return
res
;
}
void
*
(
xrealloc
)
(
void
*
ptr
,
size_t
size
)
{
xrealloc
(
void
*
ptr
,
size_t
size
)
{
/* ANSI blesses realloc (0, x) but SunOS chokes on it */
void
*
res
=
ptr
?
realloc
(
ptr
,
size
)
:
malloc
(
size
);
...
...
@@ -50,15 +56,13 @@ void *
char
*
(
xstrdup
)
(
const
char
*
str
)
{
xstrdup
(
const
char
*
str
)
{
size_t
len
=
strlen
(
str
)
+
1
;
return
memcpy
((
xmalloc
)
(
len
),
str
,
len
);
}
void
xnomem
(
void
)
{
panic
(
"out of memory"
);
xnomem
(
void
)
{
panic
(
"out of memory"
);
}
ir/adt/xmalloc.h
View file @
c6f33d8e
...
...
@@ -14,41 +14,16 @@
#ifndef _XMALLOC_H_
#define _XMALLOC_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stddef.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
/* xmalloc() & friends. */
#include "host.h"
void
*
xmalloc
(
size_t
size
);
void
*
xrealloc
(
void
*
ptr
,
size_t
size
);
char
*
xstrdup
(
const
char
*
str
);
void
xnomem
(
void
);
void
free
(
void
*
ptr
);
/* xmalloc() & friends.
The macros set tmalloc_tag to __FILE__, the functions leave it
alone. Use the latter if you set it yourself. See tmalloc.c for
details. */
extern
void
*
xmalloc
(
size_t
);
extern
void
*
xrealloc
(
void
*
,
size_t
);
extern
char
*
xstrdup
(
const
char
*
);
extern
void
xnomem
(
void
);
extern
void
free
(
void
*
);
# define xmalloc(size) (XMALLOC_TRACE (xmalloc) ((size)))
# define xrealloc(ptr, size) (XMALLOC_TRACE (xrealloc) ((ptr), (size)))
# define xstrdup(str) (XMALLOC_TRACE (xstrdup) ((str)))
# define xfree(ptr) (XMALLOC_TRACE free ((ptr)))
#if defined(HAVE_GNU_MALLOC) && defined(DEBUG)
extern
const
char
*
tmalloc_tag
;
# define XMALLOC_TRACE tmalloc_tag = __FILE__,
#else
# define XMALLOC_TRACE
#endif
#define xfree(ptr) free(ptr)
#endif
/* _XMALLOC_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment