Skip to content
Snippets Groups Projects
Commit 64a6eb05 authored by Mark Grondona's avatar Mark Grondona
Browse files

o get rid of unneeded aliases for _xmalloc etc, directly define

   calls to xmalloc to be slurm_xmalloc (...) etc.
parent e10c8730
No related branches found
No related tags found
No related merge requests found
......@@ -215,14 +215,6 @@
/* xassert.[ch] functions */
#define __xassert_failed slurm_xassert_failed
/* xmalloc.[ch] functions */
#define _xmalloc slurm_xmalloc
#define _try_xmalloc slurm_try_xmalloc
#define _xfree slurm_xfree
#define _xrealloc slurm_xrealloc
#define _try_xrealloc slurm_try_xrealloc
#define _xsize slurm_xsize
/* xsignal.[ch] functions */
#define xsignal slurm_xsignal
#define xsignal_save_mask slurm_xsignal_save_mask
......
......@@ -42,17 +42,6 @@
#include "src/common/log.h"
#include "src/common/macros.h"
/*
* Define slurm-specific aliases for use by plugins, see slurm_xlator.h
* for details.
*/
strong_alias(_xmalloc, slurm_xmalloc);
strong_alias(_try_xmalloc, slurm_try_xmalloc);
strong_alias(_xfree, slurm_xfree);
strong_alias(_xrealloc, slurm_xrealloc);
strong_alias(_try_xrealloc, slurm_try_xrealloc);
strong_alias(_xsize, slurm_xsize);
#if HAVE_UNSAFE_MALLOC
# include <pthread.h>
static pthread_mutex_t malloc_lock = PTHREAD_MUTEX_INITIALIZER;
......@@ -82,7 +71,7 @@ static void malloc_assert_failed(char *, const char *, int,
* size (IN) number of bytes to malloc
* RETURN pointer to allocate heap space
*/
void *_xmalloc(size_t size, const char *file, int line, const char *func)
void *slurm_xmalloc(size_t size, const char *file, int line, const char *func)
{
void *new;
int *p;
......@@ -110,7 +99,8 @@ void *_xmalloc(size_t size, const char *file, int line, const char *func)
/*
* same as above, except return NULL on malloc failure instead of exiting
*/
void *_try_xmalloc(size_t size, const char *file, int line, const char *func)
void *slurm_try_xmalloc(size_t size, const char *file, int line,
const char *func)
{
void *new;
int *p;
......@@ -136,8 +126,8 @@ void *_try_xmalloc(size_t size, const char *file, int line, const char *func)
* item (IN/OUT) double-pointer to allocated space
* newsize (IN) requested size
*/
void * _xrealloc(void **item, size_t newsize,
const char *file, int line, const char *func)
void * slurm_xrealloc(void **item, size_t newsize,
const char *file, int line, const char *func)
{
int *p = NULL;
......@@ -192,8 +182,8 @@ void * _xrealloc(void **item, size_t newsize,
* same as above, but return <= 0 on malloc() failure instead of aborting.
* `*item' will be unchanged.
*/
int _try_xrealloc(void **item, size_t newsize,
const char *file, int line, const char *func)
int slurm_try_xrealloc(void **item, size_t newsize,
const char *file, int line, const char *func)
{
int *p = NULL;
......@@ -244,7 +234,7 @@ int _try_xrealloc(void **item, size_t newsize,
* Return the size of a buffer.
* item (IN) pointer to allocated space
*/
int _xsize(void *item, const char *file, int line, const char *func)
int slurm_xsize(void *item, const char *file, int line, const char *func)
{
int *p = (int *)item - 2;
xmalloc_assert(item != NULL);
......@@ -257,7 +247,7 @@ int _xsize(void *item, const char *file, int line, const char *func)
* object.
* item (IN/OUT) double-pointer to allocated space
*/
void _xfree(void **item, const char *file, int line, const char *func)
void slurm_xfree(void **item, const char *file, int line, const char *func)
{
if (*item != NULL) {
int *p = (int *)*item - 2;
......
......@@ -71,33 +71,32 @@
#include "macros.h"
#define xmalloc(__sz) \
_xmalloc (__sz, __FILE__, __LINE__, __CURRENT_FUNC__)
#define xmalloc(__sz) \
slurm_xmalloc (__sz, __FILE__, __LINE__, __CURRENT_FUNC__)
#define try_xmalloc(__sz) \
_try_xmalloc(__sz, __FILE__, __LINE__, __CURRENT_FUNC__)
#define try_xmalloc(__sz) \
slurm_try_xmalloc(__sz, __FILE__, __LINE__, __CURRENT_FUNC__)
#define xfree(__p) \
_xfree((void **)&(__p), __FILE__, __LINE__, __CURRENT_FUNC__)
#define xfree(__p) \
slurm_xfree((void **)&(__p), __FILE__, __LINE__, __CURRENT_FUNC__)
#define xrealloc(__p, __sz) \
_xrealloc((void **)&(__p), __sz, __FILE__, __LINE__, __CURRENT_FUNC__)
#define xrealloc(__p, __sz) \
slurm_xrealloc((void **)&(__p), __sz, \
__FILE__, __LINE__, __CURRENT_FUNC__)
#define try_xrealloc(__p, __sz) \
_try_xrealloc((void **)&(__p), __sz, __FILE__, __LINE__, \
__CURRENT_FUNC__)
slurm_try_xrealloc((void **)&(__p), __sz, \
__FILE__, __LINE__, __CURRENT_FUNC__)
#define xsize(__p) \
_xsize((void *)__p, __FILE__, __LINE__, __CURRENT_FUNC__)
#define xsize(__p) \
slurm_xsize((void *)__p, __FILE__, __LINE__, __CURRENT_FUNC__)
void *_xmalloc(size_t size, const char *file, int line, const char *func);
void *_try_xmalloc(size_t size, const char *file, int line, const char *func);
void _xfree(void **p, const char *file, int line, const char *func);
void *_xrealloc(void **p, size_t newsize,
const char *file, int line, const char *func);
int _try_xrealloc(void **p, size_t newsize,
const char *file, int line, const char *func);
int _xsize(void *p, const char *file, int line, const char *func);
void *slurm_xmalloc(size_t, const char *, int, const char *);
void *slurm_try_xmalloc(size_t , const char *, int , const char *);
void slurm_xfree(void **, const char *, int, const char *);
void *slurm_xrealloc(void **, size_t, const char *, int, const char *);
int slurm_try_xrealloc(void **, size_t, const char *, int, const char *);
int slurm_xsize(void *, const char *, int, const char *);
#define XMALLOC_MAGIC 0x42
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment