mirror of
https://github.com/postgres/postgres.git
synced 2025-05-03 22:24:49 +03:00
This improves on commit bbfd7edae5aa5ad5553d3c7e102f2e450d4380d4 by making two simple changes: * pg_attribute_noreturn now takes parentheses, ie pg_attribute_noreturn(). Likewise pg_attribute_unused(), pg_attribute_packed(). This reduces pgindent's tendency to misformat declarations involving them. * attributes are now always attached to function declarations, not definitions. Previously some places were taking creative shortcuts, which were not merely candidates for bad misformatting by pgindent but often were outright wrong anyway. (It does little good to put a noreturn annotation where callers can't see it.) In any case, if we would like to believe that these macros can be used with non-gcc compilers, we should avoid gratuitous variance in usage patterns. I also went through and manually improved the formatting of a lot of declarations, and got rid of excessively repetitive (and now obsolete anyway) comments informing the reader what pg_attribute_printf is for.
31 lines
1.0 KiB
C
31 lines
1.0 KiB
C
/*
|
|
* fe_memutils.h
|
|
* memory management support for frontend code
|
|
*
|
|
* Copyright (c) 2003-2015, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/common/fe_memutils.h
|
|
*/
|
|
#ifndef FE_MEMUTILS_H
|
|
#define FE_MEMUTILS_H
|
|
|
|
/* "Safe" memory allocation functions --- these exit(1) on failure */
|
|
extern char *pg_strdup(const char *in);
|
|
extern void *pg_malloc(size_t size);
|
|
extern void *pg_malloc0(size_t size);
|
|
extern void *pg_realloc(void *pointer, size_t size);
|
|
extern void pg_free(void *pointer);
|
|
|
|
/* Equivalent functions, deliberately named the same as backend functions */
|
|
extern char *pstrdup(const char *in);
|
|
extern void *palloc(Size size);
|
|
extern void *palloc0(Size size);
|
|
extern void *repalloc(void *pointer, Size size);
|
|
extern void pfree(void *pointer);
|
|
|
|
/* sprintf into a palloc'd buffer --- these are in psprintf.c */
|
|
extern char *psprintf(const char *fmt,...) pg_attribute_printf(1, 2);
|
|
extern size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pg_attribute_printf(3, 0);
|
|
|
|
#endif /* FE_MEMUTILS_H */
|