diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dix-config.h.in | 3 | ||||
-rw-r--r-- | include/os.h | 31 | ||||
-rw-r--r-- | include/xorg-server.h.in | 3 |
3 files changed, 34 insertions, 3 deletions
diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 1aa77a5eb..86cf6f212 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -149,6 +149,9 @@ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ #undef HAVE_NDIR_H +/* Define to 1 if you have the `reallocarray' function. */ +#undef HAVE_REALLOCARRAY + /* Define to 1 if you have the <rpcsvc/dbm.h> header file. */ #undef HAVE_RPCSVC_DBM_H diff --git a/include/os.h b/include/os.h index 3e68c4933..6638c8443 100644 --- a/include/os.h +++ b/include/os.h @@ -69,11 +69,15 @@ typedef struct _NewClientRec *NewClientPtr; #ifndef xnfalloc #define xnfalloc(size) XNFalloc((unsigned long)(size)) -#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size)) +#define xnfcalloc(_num, _size) XNFcallocarray((_num), (_size)) #define xnfrealloc(ptr, size) XNFrealloc((void *)(ptr), (unsigned long)(size)) #define xstrdup(s) Xstrdup(s) #define xnfstrdup(s) XNFstrdup(s) + +#define xallocarray(num, size) reallocarray(NULL, (num), (size)) +#define xnfallocarray(num, size) XNFreallocarray(NULL, (num), (size)) +#define xnfreallocarray(ptr, num, size) XNFreallocarray((ptr), (num), (size)) #endif #include <stdio.h> @@ -222,7 +226,14 @@ XNFalloc(unsigned long /*amount */ ); * enough memory. */ extern _X_EXPORT void * -XNFcalloc(unsigned long /*amount */ ); +XNFcalloc(unsigned long /*amount */ ) _X_DEPRECATED; + +/* + * This function calloc(3)s buffer, terminating the server if there is not + * enough memory or the arguments overflow when multiplied + */ +extern _X_EXPORT void * +XNFcallocarray(size_t nmemb, size_t size); /* * This function realloc(3)s passed buffer, terminating the server if there is @@ -232,6 +243,13 @@ extern _X_EXPORT void * XNFrealloc(void * /*ptr */ , unsigned long /*amount */ ); /* + * This function reallocarray(3)s passed buffer, terminating the server if + * there is not enough memory or the arguments overflow when multiplied. + */ +extern _X_EXPORT void * +XNFreallocarray(void *ptr, size_t nmemb, size_t size); + +/* * This function strdup(3)s passed string. The only difference from the library * function that it is safe to pass NULL, as NULL will be returned. */ @@ -510,7 +528,14 @@ ddxGiveUp(enum ExitCode error); extern _X_EXPORT int TimeSinceLastInputEvent(void); -/* strcasecmp.c */ +/* Function fallbacks provided by AC_REPLACE_FUNCS in configure.ac */ + +#ifndef HAVE_REALLOCARRAY +#define reallocarray xreallocarray +extern _X_EXPORT void * +reallocarray(void *optr, size_t nmemb, size_t size); +#endif + #ifndef HAVE_STRCASECMP #define strcasecmp xstrcasecmp extern _X_EXPORT int diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in index 4cb94875c..3152dbd68 100644 --- a/include/xorg-server.h.in +++ b/include/xorg-server.h.in @@ -47,6 +47,9 @@ /* Define to 1 if you have the `ffs' function. */ #undef HAVE_FFS +/* Define to 1 if you have the `reallocarray' function. */ +#undef HAVE_REALLOCARRAY + /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP |