From 5a9f5c60dae8d173e9e2f6da78499c046600e6ca Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 29 Apr 2012 23:40:06 -0500 Subject: Convert ALLOC_FAIL macro into a function This path is rarely (read: never) taken in any normal run of the code, so injecting the fprintf() call everywhere with the macro is a bit overkill. Instead, add a lightweight _alpm_alloc_fail() function that gets called instead. This does have a reasonable effect on the size of the generated code; most places using the macros provided by util.c have their code size reduced. Signed-off-by: Dan McGee --- lib/libalpm/util.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index a392c773..996d7f4e 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -1247,6 +1247,11 @@ int _alpm_fnmatch(const void *pattern, const void *string) return fnmatch(pattern, string, 0); } +void _alpm_alloc_fail(size_t size) +{ + fprintf(stderr, "alloc failure: could not allocate %zd bytes\n", size); +} + #ifndef HAVE_STRNDUP /* A quick and dirty implementation derived from glibc */ /** Determines the length of a fixed-size string. -- cgit v1.2.3-24-g4f1b