os: Remove deprecated malloc/free wrappers
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
d5b2799772
commit
cad9b053d5
|
@ -1217,11 +1217,9 @@ library is contained in dix/dixfonts.c
|
||||||
<section>
|
<section>
|
||||||
<title>Memory Management</title>
|
<title>Memory Management</title>
|
||||||
<para>
|
<para>
|
||||||
Memory management is based on functions in the C runtime library.
|
Memory management is based on functions in the C runtime library, malloc(),
|
||||||
Xalloc(), Xrealloc(), and Xfree() are deprecated aliases for malloc(),
|
|
||||||
realloc(), and free(), and you should simply call the C library functions
|
realloc(), and free(), and you should simply call the C library functions
|
||||||
directly. Consult a C runtime library reference
|
directly. Consult a C runtime library reference manual for more details.
|
||||||
manual for more details.
|
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Treat memory allocation carefully in your implementation. Memory
|
Treat memory allocation carefully in your implementation. Memory
|
||||||
|
|
37
include/os.h
37
include/os.h
|
@ -67,15 +67,11 @@ SOFTWARE.
|
||||||
typedef struct _FontPathRec *FontPathPtr;
|
typedef struct _FontPathRec *FontPathPtr;
|
||||||
typedef struct _NewClientRec *NewClientPtr;
|
typedef struct _NewClientRec *NewClientPtr;
|
||||||
|
|
||||||
#ifndef xalloc
|
#ifndef xnfalloc
|
||||||
#define xnfalloc(size) XNFalloc((unsigned long)(size))
|
#define xnfalloc(size) XNFalloc((unsigned long)(size))
|
||||||
#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
|
#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
|
||||||
#define xnfrealloc(ptr, size) XNFrealloc((void *)(ptr), (unsigned long)(size))
|
#define xnfrealloc(ptr, size) XNFrealloc((void *)(ptr), (unsigned long)(size))
|
||||||
|
|
||||||
#define xalloc(size) Xalloc((unsigned long)(size))
|
|
||||||
#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size))
|
|
||||||
#define xrealloc(ptr, size) Xrealloc((void *)(ptr), (unsigned long)(size))
|
|
||||||
#define xfree(ptr) Xfree((void *)(ptr))
|
|
||||||
#define xstrdup(s) Xstrdup(s)
|
#define xstrdup(s) Xstrdup(s)
|
||||||
#define xnfstrdup(s) XNFstrdup(s)
|
#define xnfstrdup(s) XNFstrdup(s)
|
||||||
#endif
|
#endif
|
||||||
|
@ -214,37 +210,6 @@ extern _X_EXPORT int set_font_authorizations(char **authorizations,
|
||||||
int *authlen,
|
int *authlen,
|
||||||
void *client);
|
void *client);
|
||||||
|
|
||||||
#ifndef _HAVE_XALLOC_DECLS
|
|
||||||
#define _HAVE_XALLOC_DECLS
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use malloc(3) instead.
|
|
||||||
*/
|
|
||||||
extern _X_EXPORT void *
|
|
||||||
Xalloc(unsigned long /*amount */ ) _X_DEPRECATED;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use calloc(3) instead
|
|
||||||
*/
|
|
||||||
extern _X_EXPORT void *
|
|
||||||
Xcalloc(unsigned long /*amount */ ) _X_DEPRECATED;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use realloc(3) instead
|
|
||||||
*/
|
|
||||||
extern _X_EXPORT void *
|
|
||||||
Xrealloc(void * /*ptr */ , unsigned long /*amount */ )
|
|
||||||
_X_DEPRECATED;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use free(3) instead
|
|
||||||
*/
|
|
||||||
extern _X_EXPORT void
|
|
||||||
Xfree(void * /*ptr */ )
|
|
||||||
_X_DEPRECATED;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function malloc(3)s buffer, terminating the server if there is not
|
* This function malloc(3)s buffer, terminating the server if there is not
|
||||||
* enough memory.
|
* enough memory.
|
||||||
|
|
48
os/utils.c
48
os/utils.c
|
@ -1089,24 +1089,6 @@ set_font_authorizations(char **authorizations, int *authlen, void *client)
|
||||||
#endif /* TCPCONN */
|
#endif /* TCPCONN */
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
Xalloc(unsigned long amount)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Xalloc used to return NULL when large amount of memory is requested. In
|
|
||||||
* order to catch the buggy callers this warning has been added, slated to
|
|
||||||
* removal by anyone who touches this code (or just looks at it) in 2011.
|
|
||||||
*
|
|
||||||
* -- Mikhail Gusarov
|
|
||||||
*/
|
|
||||||
if ((long) amount <= 0)
|
|
||||||
ErrorF("Warning: Xalloc: "
|
|
||||||
"requesting unpleasantly large amount of memory: %lu bytes.\n",
|
|
||||||
amount);
|
|
||||||
|
|
||||||
return malloc(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
XNFalloc(unsigned long amount)
|
XNFalloc(unsigned long amount)
|
||||||
{
|
{
|
||||||
|
@ -1117,12 +1099,6 @@ XNFalloc(unsigned long amount)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
Xcalloc(unsigned long amount)
|
|
||||||
{
|
|
||||||
return calloc(1, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
XNFcalloc(unsigned long amount)
|
XNFcalloc(unsigned long amount)
|
||||||
{
|
{
|
||||||
|
@ -1133,24 +1109,6 @@ XNFcalloc(unsigned long amount)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
Xrealloc(void *ptr, unsigned long amount)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Xrealloc used to return NULL when large amount of memory is requested. In
|
|
||||||
* order to catch the buggy callers this warning has been added, slated to
|
|
||||||
* removal by anyone who touches this code (or just looks at it) in 2011.
|
|
||||||
*
|
|
||||||
* -- Mikhail Gusarov
|
|
||||||
*/
|
|
||||||
if ((long) amount <= 0)
|
|
||||||
ErrorF("Warning: Xrealloc: "
|
|
||||||
"requesting unpleasantly large amount of memory: %lu bytes.\n",
|
|
||||||
amount);
|
|
||||||
|
|
||||||
return realloc(ptr, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
XNFrealloc(void *ptr, unsigned long amount)
|
XNFrealloc(void *ptr, unsigned long amount)
|
||||||
{
|
{
|
||||||
|
@ -1161,12 +1119,6 @@ XNFrealloc(void *ptr, unsigned long amount)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Xfree(void *ptr)
|
|
||||||
{
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
Xstrdup(const char *s)
|
Xstrdup(const char *s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user