summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-17 17:19:38 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-19 10:10:41 -0400
commit31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7 (patch)
tree2f16e9f5adb26c4ef2f50f85cda9042de8243efc /src/shared
parentbdd29249a882e599e5e365536372d08dee398cd4 (diff)
core/killall: use procfs_file_alloca
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c9
-rw-r--r--src/shared/util.h10
2 files changed, 10 insertions, 9 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 1fc6c5aa1a..a6ec79a292 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -80,15 +80,6 @@ char **saved_argv = NULL;
static volatile unsigned cached_columns = 0;
static volatile unsigned cached_lines = 0;
-#define procfs_file_alloca(pid, field) \
- ({ \
- pid_t _pid_ = (pid); \
- char *_r_; \
- _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
- sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \
- _r_; \
- })
-
size_t page_size(void) {
static __thread size_t pgsz = 0;
long r;
diff --git a/src/shared/util.h b/src/shared/util.h
index cfb54939cd..6575f56811 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -21,6 +21,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <alloca.h>
#include <inttypes.h>
#include <time.h>
#include <sys/time.h>
@@ -696,3 +697,12 @@ int unlink_noerrno(const char *path);
strcpy(stpcpy(_c_, _a_), _b_); \
_c_; \
})
+
+#define procfs_file_alloca(pid, field) \
+ ({ \
+ pid_t _pid_ = (pid); \
+ char *_r_; \
+ _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
+ sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \
+ _r_; \
+ })