Start 1.33.0 development cycle
[oweals/busybox.git] / libbb / auto_string.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Utility routines.
4  *
5  * Copyright (C) 2015 Denys Vlasenko
6  *
7  * Licensed under GPLv2, see file LICENSE in this source tree.
8  */
9 //kbuild:lib-y += auto_string.o
10
11 #include "libbb.h"
12
13 char* FAST_FUNC auto_string(char *str)
14 {
15         static char *saved[4];
16         static uint8_t cur_saved; /* = 0 */
17
18         free(saved[cur_saved]);
19         saved[cur_saved] = str;
20         cur_saved = (cur_saved + 1) & (ARRAY_SIZE(saved)-1);
21
22         return str;
23 }