diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-06-30 11:52:50 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-06-30 11:52:50 -0700 |
commit | b99e6cbd055fbf8664ee510c2e60854d10c69d51 (patch) | |
tree | 53218c51ecee99f378698a00ffcc20d88b6dd3df | |
parent | 8301a96e8f11f668a717afbdf95f3695cdc9ca3b (diff) | |
download | libnodelay-1.0.1.tar.gz |
do not rely on implementation-specific behavior for allocation v1.0.1
C compilers are free to release stack-allocated memory once it exits the scope of any block (even though most do not). Thanks to Leonid Evdokimov for pointing this out.
-rw-r--r-- | nodelay.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -72,11 +72,13 @@ int socket(int domain, int type, int protocol) int setsockopt(int sockfd, int level, int optname, const void *poptval, socklen_t optlen) { + int optval; + if (unlikely(!real_socket)) nodelay_init(); if (level == IPPROTO_TCP && optname == TCP_NODELAY) { - int optval = nodelay_value; + optval = nodelay_value; poptval = &optval; optlen = sizeof(optval); |