summaryrefslogtreecommitdiff
path: root/libgcompat
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2018-01-14 22:27:11 -0600
committerSamuel Holland <samuel@sholland.org>2018-01-15 00:02:54 -0600
commitc735fc99ec9e96520da0ea938890eed8fe64b50e (patch)
treeb12915ce6e3e331c0a9769048dc7f1e7bf30ddce /libgcompat
parentd3e8ee9b447b1b60619f8688abe0dd992c383701 (diff)
downloadgcompat-c735fc99ec9e96520da0ea938890eed8fe64b50e.tar.gz
gcompat-c735fc99ec9e96520da0ea938890eed8fe64b50e.tar.bz2
gcompat-c735fc99ec9e96520da0ea938890eed8fe64b50e.tar.xz
gcompat-c735fc99ec9e96520da0ea938890eed8fe64b50e.zip
resource: Minor improvements
* Make function pointer static. * Only initialize function pointer once. Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'libgcompat')
-rw-r--r--libgcompat/resource.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libgcompat/resource.c b/libgcompat/resource.c
index 4a7ab4e..836d5e2 100644
--- a/libgcompat/resource.c
+++ b/libgcompat/resource.c
@@ -17,16 +17,17 @@
* very obviously won't work here.
*/
#ifndef NO_BROKEN_SHADOW_SETRLIMIT
-int (*real_rlimit)(int, const struct rlimit *);
+static int (*real_rlimit)(int, const struct rlimit *);
int setrlimit(int resource, const struct rlimit *rlim)
{
struct rlimit my_rlim;
- real_rlimit = dlsym(RTLD_NEXT, "setrlimit");
- assert(real_rlimit != NULL);
+ if (real_rlimit == NULL) {
+ real_rlimit = dlsym(RTLD_NEXT, "setrlimit");
+ assert(real_rlimit);
+ }
memcpy(&my_rlim, rlim, sizeof(struct rlimit));
-
if (my_rlim.rlim_cur == 0) {
my_rlim.rlim_cur = my_rlim.rlim_max;
}