lj_str.h 940 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. ** String handling.
  3. ** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
  4. */
  5. #ifndef _LJ_STR_H
  6. #define _LJ_STR_H
  7. #include <stdarg.h>
  8. #include "lj_obj.h"
  9. /* String helpers. */
  10. LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b);
  11. LJ_FUNC const char *lj_str_find(const char *s, const char *f,
  12. MSize slen, MSize flen);
  13. LJ_FUNC int lj_str_haspattern(GCstr *s);
  14. /* String interning. */
  15. LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask);
  16. LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len);
  17. LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s);
  18. LJ_FUNC void LJ_FASTCALL lj_str_init(lua_State *L);
  19. #define lj_str_freetab(g) \
  20. (lj_mem_freevec(g, g->str.tab, g->str.mask+1, GCRef))
  21. #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s)))
  22. #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1))
  23. #define lj_str_size(len) (sizeof(GCstr) + (((len)+4) & ~(MSize)3))
  24. #endif