get_system_dir.c 487 B

123456789101112131415161718192021
  1. /*
  2. * Wrapper function around GetSystemDirectory that deals with
  3. * allocating the output buffer, and also caches the result for future
  4. * calls.
  5. */
  6. #include "putty.h"
  7. const char *get_system_dir(void)
  8. {
  9. static char *sysdir = NULL;
  10. static size_t sysdirsize = 0;
  11. if (!sysdir) {
  12. size_t len;
  13. while ((len = GetSystemDirectory(sysdir, sysdirsize)) >= sysdirsize)
  14. sgrowarray(sysdir, sysdirsize, len);
  15. }
  16. return sysdir;
  17. }