3
0

auto_string.c 435 B

1234567891011121314151617181920212223
  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. #include "libbb.h"
  11. char* FAST_FUNC auto_string(char *str)
  12. {
  13. static char *saved[4];
  14. static uint8_t cur_saved; /* = 0 */
  15. free(saved[cur_saved]);
  16. saved[cur_saved] = str;
  17. cur_saved = (cur_saved + 1) & (ARRAY_SIZE(saved)-1);
  18. return str;
  19. }