iodine 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of iodine might be problematic. Click here for more details.

Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +4 -4
  4. data/SPEC-Websocket-Draft.md +3 -6
  5. data/bin/mustache.rb +128 -0
  6. data/examples/test_template.mustache +16 -0
  7. data/ext/iodine/fio.c +9397 -0
  8. data/ext/iodine/fio.h +4723 -0
  9. data/ext/iodine/fio_ary.h +353 -54
  10. data/ext/iodine/fio_cli.c +351 -361
  11. data/ext/iodine/fio_cli.h +84 -105
  12. data/ext/iodine/fio_hashmap.h +70 -16
  13. data/ext/iodine/fio_json_parser.h +35 -24
  14. data/ext/iodine/fio_siphash.c +104 -4
  15. data/ext/iodine/fio_siphash.h +18 -2
  16. data/ext/iodine/fio_str.h +1218 -0
  17. data/ext/iodine/fio_tmpfile.h +1 -1
  18. data/ext/iodine/fiobj.h +13 -8
  19. data/ext/iodine/fiobj4sock.h +6 -8
  20. data/ext/iodine/fiobj_ary.c +107 -17
  21. data/ext/iodine/fiobj_ary.h +36 -4
  22. data/ext/iodine/fiobj_data.c +146 -127
  23. data/ext/iodine/fiobj_data.h +25 -23
  24. data/ext/iodine/fiobj_hash.c +7 -7
  25. data/ext/iodine/fiobj_hash.h +6 -5
  26. data/ext/iodine/fiobj_json.c +20 -17
  27. data/ext/iodine/fiobj_json.h +5 -5
  28. data/ext/iodine/fiobj_mem.h +71 -0
  29. data/ext/iodine/fiobj_mustache.c +310 -0
  30. data/ext/iodine/fiobj_mustache.h +40 -0
  31. data/ext/iodine/fiobj_numbers.c +199 -94
  32. data/ext/iodine/fiobj_numbers.h +7 -7
  33. data/ext/iodine/fiobj_str.c +142 -333
  34. data/ext/iodine/fiobj_str.h +65 -55
  35. data/ext/iodine/fiobject.c +49 -11
  36. data/ext/iodine/fiobject.h +40 -39
  37. data/ext/iodine/http.c +382 -190
  38. data/ext/iodine/http.h +124 -80
  39. data/ext/iodine/http1.c +99 -127
  40. data/ext/iodine/http1.h +5 -5
  41. data/ext/iodine/http1_parser.c +3 -2
  42. data/ext/iodine/http1_parser.h +2 -2
  43. data/ext/iodine/http_internal.c +14 -12
  44. data/ext/iodine/http_internal.h +25 -19
  45. data/ext/iodine/iodine.c +37 -18
  46. data/ext/iodine/iodine.h +4 -0
  47. data/ext/iodine/iodine_caller.c +9 -2
  48. data/ext/iodine/iodine_caller.h +2 -0
  49. data/ext/iodine/iodine_connection.c +82 -117
  50. data/ext/iodine/iodine_defer.c +57 -50
  51. data/ext/iodine/iodine_defer.h +0 -1
  52. data/ext/iodine/iodine_fiobj2rb.h +4 -2
  53. data/ext/iodine/iodine_helpers.c +4 -4
  54. data/ext/iodine/iodine_http.c +25 -32
  55. data/ext/iodine/iodine_json.c +2 -1
  56. data/ext/iodine/iodine_mustache.c +423 -0
  57. data/ext/iodine/iodine_mustache.h +6 -0
  58. data/ext/iodine/iodine_pubsub.c +48 -153
  59. data/ext/iodine/iodine_pubsub.h +5 -4
  60. data/ext/iodine/iodine_rack_io.c +7 -5
  61. data/ext/iodine/iodine_store.c +16 -13
  62. data/ext/iodine/iodine_tcp.c +26 -34
  63. data/ext/iodine/mustache_parser.h +1085 -0
  64. data/ext/iodine/redis_engine.c +740 -646
  65. data/ext/iodine/redis_engine.h +13 -15
  66. data/ext/iodine/resp_parser.h +11 -5
  67. data/ext/iodine/websocket_parser.h +13 -13
  68. data/ext/iodine/websockets.c +240 -393
  69. data/ext/iodine/websockets.h +52 -113
  70. data/lib/iodine.rb +1 -1
  71. data/lib/iodine/mustache.rb +140 -0
  72. data/lib/iodine/version.rb +1 -1
  73. metadata +15 -28
  74. data/ext/iodine/defer.c +0 -566
  75. data/ext/iodine/defer.h +0 -148
  76. data/ext/iodine/evio.c +0 -26
  77. data/ext/iodine/evio.h +0 -161
  78. data/ext/iodine/evio_callbacks.c +0 -26
  79. data/ext/iodine/evio_epoll.c +0 -251
  80. data/ext/iodine/evio_kqueue.c +0 -194
  81. data/ext/iodine/facil.c +0 -2325
  82. data/ext/iodine/facil.h +0 -616
  83. data/ext/iodine/fio_base64.c +0 -277
  84. data/ext/iodine/fio_base64.h +0 -71
  85. data/ext/iodine/fio_llist.h +0 -257
  86. data/ext/iodine/fio_mem.c +0 -675
  87. data/ext/iodine/fio_mem.h +0 -143
  88. data/ext/iodine/fio_random.c +0 -248
  89. data/ext/iodine/fio_random.h +0 -45
  90. data/ext/iodine/fio_sha1.c +0 -362
  91. data/ext/iodine/fio_sha1.h +0 -107
  92. data/ext/iodine/fio_sha2.c +0 -842
  93. data/ext/iodine/fio_sha2.h +0 -169
  94. data/ext/iodine/pubsub.c +0 -867
  95. data/ext/iodine/pubsub.h +0 -221
  96. data/ext/iodine/sock.c +0 -1366
  97. data/ext/iodine/sock.h +0 -566
  98. data/ext/iodine/spnlock.inc +0 -111
@@ -5,7 +5,7 @@ License: MIT
5
5
  */
6
6
  #define H_FIOBJ_STR_H
7
7
 
8
- #include "fiobject.h"
8
+ #include <fiobject.h>
9
9
 
10
10
  #ifdef __cplusplus
11
11
  extern "C" {
@@ -20,37 +20,33 @@ API: Creating a String Object
20
20
  /** Creates a String object. Remember to use `fiobj_free`. */
21
21
  FIOBJ fiobj_str_new(const char *str, size_t len);
22
22
 
23
- /** Creates a buffer String object. capa includes NUL.
24
- *
25
- * Remember to use `fiobj_free`.
26
- */
27
- FIOBJ fiobj_str_buf(size_t capa);
28
-
29
23
  /**
30
- * Creates a static String object from a static C string. Remember `fiobj_free`.
31
- *
32
- * This variation avoids allocating memory for an existing static String.
24
+ * Creates a String object with pre-allocation for Strings up to `capa` long.
33
25
  *
34
- * The object still needs to be frees, but the string isn't copied and isn't
35
- * freed.
26
+ * If `capa` is zero, a whole memory page will be allocated.
36
27
  *
37
- * NOTICE: static strings can't be written to.
28
+ * Remember to use `fiobj_free`.
38
29
  */
39
- FIOBJ fiobj_str_static(const char *str, size_t len);
30
+ FIOBJ fiobj_str_buf(size_t capa);
40
31
 
41
32
  /** Creates a copy from an existing String. Remember to use `fiobj_free`. */
42
33
  static inline __attribute__((unused)) FIOBJ fiobj_str_copy(FIOBJ src) {
43
- fio_cstr_s s = fiobj_obj2cstr(src);
34
+ fio_str_info_s s = fiobj_obj2cstr(src);
44
35
  return fiobj_str_new(s.data, s.len);
45
36
  }
46
37
 
47
38
  /**
48
39
  * Creates a String object. Remember to use `fiobj_free`.
49
40
  *
50
- * The ownership of the memory indicated by `str` will now "move" to the object.
41
+ * It's possible to wrap a previosly allocated memory block in a FIOBJ String
42
+ * object, as long as it was allocated using `fio_malloc`.
43
+ *
44
+ * The ownership of the memory indicated by `str` will "move" to the object and
45
+ * will be freed (using `fio_free`) once the object's reference count drops to
46
+ * zero.
51
47
  *
52
- * The original memory MUST be allocated using `fio_malloc` (NOT the system's
53
- * `malloc`) and it will be freed by the `fiobj` library using `fio_free`.
48
+ * Note: The original memory MUST be allocated using `fio_malloc` (NOT the
49
+ * system's `malloc`) and it will be freed using `fio_free`.
54
50
  */
55
51
  FIOBJ fiobj_str_move(char *str, size_t len, size_t capacity);
56
52
 
@@ -60,29 +56,6 @@ FIOBJ fiobj_str_move(char *str, size_t len, size_t capacity);
60
56
  */
61
57
  FIOBJ fiobj_str_tmp(void);
62
58
 
63
- /** Creates a String object using a printf like interface. */
64
- __attribute__((format(printf, 1, 0))) FIOBJ fiobj_strvprintf(const char *format,
65
- va_list argv);
66
-
67
- /** Creates a String object using a printf like interface. */
68
- __attribute__((format(printf, 1, 2))) FIOBJ fiobj_strprintf(const char *format,
69
- ...);
70
-
71
- /** Dumps the `filename` file's contents into a new String. If `limit == 0`,
72
- * than the data will be read until EOF.
73
- *
74
- * If the file can't be located, opened or read, or if `start_at` is out of
75
- * bounds (i.e., beyond the EOF position), FIOBJ_INVALID is returned.
76
- *
77
- * If `start_at` is negative, it will be computed from the end of the file.
78
- *
79
- * Remember to use `fiobj_free`.
80
- *
81
- * NOTE: Requires a UNIX system, otherwise always returns FIOBJ_INVALID.
82
- */
83
- FIOBJ fiobj_str_readfile(const char *filename, intptr_t start_at,
84
- intptr_t limit);
85
-
86
59
  /* *****************************************************************************
87
60
  API: Editing a String
88
61
  ***************************************************************************** */
@@ -90,29 +63,35 @@ API: Editing a String
90
63
  /**
91
64
  * Prevents the String object from being changed.
92
65
  *
93
- * When a String is used as a key for a Hash, it is automatically frozenn to
66
+ * When a String is used as a key for a Hash, it is automatically frozen to
94
67
  * prevent the Hash from becoming broken.
95
- *
96
- * A call to `fiobj_str_hash` or `fiobj_obj2hash` will automactically freeze the
97
- * String.
98
68
  */
99
69
  void fiobj_str_freeze(FIOBJ str);
100
70
 
101
71
  /**
102
- * Confirms the requested capacity is available and allocates as required.
72
+ * Confirms the String allows for the requested capacity (counting used space as
73
+ * well as free space).
103
74
  *
104
75
  * Returns updated capacity.
105
76
  */
106
77
  size_t fiobj_str_capa_assert(FIOBJ str, size_t size);
107
78
 
108
- /** Return's a String's capacity, if any. This should include the NUL byte. */
79
+ /** Returns a String's capacity, if any. This should include the NUL byte. */
109
80
  size_t fiobj_str_capa(FIOBJ str);
110
81
 
111
82
  /** Resizes a String object, allocating more memory if required. */
112
83
  void fiobj_str_resize(FIOBJ str, size_t size);
113
84
 
114
- /** Deallocates any unnecessary memory (if supported by OS). */
115
- void fiobj_str_minimize(FIOBJ str);
85
+ /**
86
+ * Performs a best attempt at minimizing memory consumption.
87
+ *
88
+ * Actual effects depend on the underlying memory allocator and it's
89
+ * implementation. Not all allocators will free any memory.
90
+ */
91
+ void fiobj_str_compact(FIOBJ str);
92
+
93
+ /** Alias for `fiobj_str_compact`. */
94
+ #define fiobj_str_minimize(str) fiobj_str_compact((str))
116
95
 
117
96
  /** Empties a String's data. */
118
97
  void fiobj_str_clear(FIOBJ str);
@@ -124,11 +103,27 @@ void fiobj_str_clear(FIOBJ str);
124
103
  size_t fiobj_str_write(FIOBJ dest, const char *data, size_t len);
125
104
 
126
105
  /**
127
- * Writes data at the end of the string, resizing the string as required.
106
+ * Writes a number at the end of the String using normal base 10 notation.
107
+ *
128
108
  * Returns the new length of the String
129
109
  */
110
+ size_t fiobj_str_write_i(FIOBJ dest, int64_t num);
111
+
112
+ /**
113
+ * Writes data at the end of the string using a printf like interface, resizing
114
+ * the string as required. Returns the new length of the String
115
+ */
130
116
  __attribute__((format(printf, 2, 3))) size_t
131
- fiobj_str_write2(FIOBJ dest, const char *format, ...);
117
+ fiobj_str_printf(FIOBJ dest, const char *format, ...);
118
+
119
+ /**
120
+ * Writes data at the end of the string using a vprintf like interface, resizing
121
+ * the string as required.
122
+ *
123
+ * Returns the new length of the String
124
+ */
125
+ __attribute__((format(printf, 2, 0))) size_t
126
+ fiobj_str_vprintf(FIOBJ dest, const char *format, va_list argv);
132
127
 
133
128
  /**
134
129
  * Writes data at the end of the string, resizing the string as required.
@@ -137,7 +132,25 @@ fiobj_str_write2(FIOBJ dest, const char *format, ...);
137
132
  *
138
133
  * Returns the new length of the String.
139
134
  */
140
- size_t fiobj_str_join(FIOBJ dest, FIOBJ source);
135
+ size_t fiobj_str_concat(FIOBJ dest, FIOBJ source);
136
+ #define fiobj_str_join(dest, src) fiobj_str_concat((dest), (src))
137
+
138
+ /**
139
+ * Dumps the `filename` file's contents at the end of the String.
140
+ *
141
+ * If `limit == 0`, than the data will be read until EOF.
142
+ *
143
+ * If the file can't be located, opened or read, or if `start_at` is out of
144
+ * bounds (i.e., beyond the EOF position), FIOBJ_INVALID is returned.
145
+ *
146
+ * If `start_at` is negative, it will be computed from the end of the file.
147
+ *
148
+ * Remember to use `fiobj_free`.
149
+ *
150
+ * NOTE: Requires a UNIX system, otherwise always returns FIOBJ_INVALID.
151
+ */
152
+ size_t fiobj_str_readfile(FIOBJ dest, const char *filename, intptr_t start_at,
153
+ intptr_t limit);
141
154
 
142
155
  /* *****************************************************************************
143
156
  API: String Values
@@ -145,9 +158,6 @@ API: String Values
145
158
 
146
159
  /**
147
160
  * Calculates a String's SipHash value for possible use as a HashMap key.
148
- *
149
- * Hashing the String's value automatically freezes the string, preventing
150
- * future changes.
151
161
  */
152
162
  uint64_t fiobj_str_hash(FIOBJ o);
153
163
 
@@ -7,18 +7,53 @@ License: MIT
7
7
  This facil.io core library provides wrappers around complex and (or) dynamic
8
8
  types, abstracting some complexity and making dynamic type related tasks easier.
9
9
  */
10
- #include "fiobject.h"
10
+ #include <fiobject.h>
11
11
 
12
- #include "fio_ary.h"
13
-
14
- #define FIO_OVERRIDE_MALLOC 1
15
- #include "fio_mem.h"
12
+ #include <fio_ary.h>
16
13
 
17
14
  #include <stdarg.h>
18
15
  #include <stdint.h>
19
16
  #include <stdio.h>
20
17
  #include <stdlib.h>
21
18
 
19
+ /* *****************************************************************************
20
+ Use the facil.io allocator when available
21
+ ***************************************************************************** */
22
+
23
+ #pragma weak fio_malloc
24
+ void *__attribute__((weak)) fio_malloc(size_t size) {
25
+ void *m = malloc(size);
26
+ if (m)
27
+ memset(m, 0, size);
28
+ return m;
29
+ }
30
+
31
+ #pragma weak fio_calloc
32
+ void *__attribute__((weak)) fio_calloc(size_t size, size_t count) {
33
+ return calloc(size, count);
34
+ }
35
+
36
+ #pragma weak fio_free
37
+ void __attribute__((weak)) fio_free(void *ptr) { free(ptr); }
38
+
39
+ #pragma weak fio_realloc
40
+ void *__attribute__((weak)) fio_realloc(void *ptr, size_t new_size) {
41
+ return realloc(ptr, new_size);
42
+ }
43
+
44
+ #pragma weak fio_realloc2
45
+ void *__attribute__((weak))
46
+ fio_realloc2(void *ptr, size_t new_size, size_t valid_len) {
47
+ return realloc(ptr, new_size);
48
+ (void)valid_len;
49
+ }
50
+
51
+ #pragma weak fio_mmap
52
+ void *__attribute__((weak)) fio_mmap(size_t size) { return fio_malloc(size); }
53
+
54
+ #define FIO_OVERRIDE_MALLOC 1
55
+ #include <fiobj_mem.h>
56
+
22
57
  /* *****************************************************************************
23
58
  the `fiobj_each2` function
24
59
  ***************************************************************************** */
@@ -77,7 +112,10 @@ size_t fiobj_each2(FIOBJ o, int (*task)(FIOBJ obj, void *arg), void *arg) {
77
112
  uintptr_t pos = 0;
78
113
  fio_ary_s stack = FIO_ARY_INIT;
79
114
  struct task_packet_s packet = {
80
- .task = task, .arg = arg, .stack = &stack, .counter = 1,
115
+ .task = task,
116
+ .arg = arg,
117
+ .stack = &stack,
118
+ .counter = 1,
81
119
  };
82
120
  do {
83
121
  if (!pos)
@@ -142,7 +180,7 @@ void fiobj_free_complex_object(FIOBJ o) {
142
180
  /* *****************************************************************************
143
181
  Is Equal?
144
182
  ***************************************************************************** */
145
- #include "fiobj_hash.h"
183
+ #include <fiobj_hash.h>
146
184
 
147
185
  static inline int fiobj_iseq_simple(const FIOBJ o, const FIOBJ o2) {
148
186
  if (o == o2)
@@ -228,9 +266,9 @@ size_t fiobject___noop_is_eq(const FIOBJ o1, const FIOBJ o2) {
228
266
  return 0;
229
267
  }
230
268
 
231
- fio_cstr_s fiobject___noop_to_str(const FIOBJ o) {
269
+ fio_str_info_s fiobject___noop_to_str(const FIOBJ o) {
232
270
  (void)o;
233
- return (fio_cstr_s){.len = 0, .data = NULL};
271
+ return (fio_str_info_s){.len = 0, .data = NULL};
234
272
  }
235
273
  intptr_t fiobject___noop_to_i(const FIOBJ o) {
236
274
  (void)o;
@@ -243,8 +281,8 @@ double fiobject___noop_to_f(const FIOBJ o) {
243
281
 
244
282
  #if DEBUG
245
283
 
246
- #include "fiobj_ary.h"
247
- #include "fiobj_numbers.h"
284
+ #include <fiobj_ary.h>
285
+ #include <fiobj_numbers.h>
248
286
 
249
287
  static int fiobject_test_task(FIOBJ o, void *arg) {
250
288
  ++((uintptr_t *)arg)[0];
@@ -21,10 +21,16 @@ types, abstracting some complexity and making dynamic type related tasks easier.
21
21
  #include <stdio.h>
22
22
  #include <stdlib.h>
23
23
 
24
- #include "fio_siphash.h"
25
-
26
- #if !defined(__GNUC__)
27
- #define __attribute__(x) /* :-( */
24
+ #include <fio_siphash.h>
25
+
26
+ #if !defined(__GNUC__) && !defined(__clang__) && !defined(FIO_GNUC_BYPASS)
27
+ #define __attribute__(...)
28
+ #define __has_include(...) 0
29
+ #define __has_builtin(...) 0
30
+ #define FIO_GNUC_BYPASS 1
31
+ #elif !defined(__clang__) && __GNUC__ < 5
32
+ #define __has_builtin(...) 0
33
+ #define FIO_GNUC_BYPASS 1
28
34
  #endif
29
35
 
30
36
  #ifdef __cplusplus
@@ -56,20 +62,15 @@ typedef uintptr_t FIOBJ;
56
62
  #define FIOBJ_IS_NULL(obj) (!obj || obj == (FIOBJ)FIOBJ_T_NULL)
57
63
  #define FIOBJ_INVALID 0
58
64
 
59
- /** A string information type, reports anformation about a C string. */
60
- typedef struct {
61
- union {
62
- size_t len;
63
- size_t length;
64
- };
65
- union {
66
- void *buffer;
67
- uint8_t *bytes;
68
- char *data;
69
- char *value;
70
- char *name;
71
- };
72
- } fio_cstr_s;
65
+ #ifndef FIO_STR_INFO_TYPE
66
+ /** A String information type, reports information about a C string. */
67
+ typedef struct fio_str_info_s {
68
+ size_t capa; /* Buffer capacity, if the string is writable. */
69
+ size_t len; /* String length. */
70
+ char *data; /* String's first byte. */
71
+ } fio_str_info_s;
72
+ #define FIO_STR_INFO_TYPE
73
+ #endif
73
74
 
74
75
  /* *****************************************************************************
75
76
  Primitives
@@ -89,8 +90,10 @@ Generic Object API
89
90
  FIO_INLINE const char *fiobj_type_name(const FIOBJ obj);
90
91
 
91
92
  /**
92
- * Heruistic copy with a preference for copy reference(!) to minimize
93
- * allocations. reference count.
93
+ * Heuristic copy with a preference for copy reference(!) to minimize
94
+ * allocations.
95
+ *
96
+ * Always returns the value passed along.
94
97
  */
95
98
  FIO_INLINE FIOBJ fiobj_dup(FIOBJ);
96
99
 
@@ -136,7 +139,7 @@ FIO_INLINE intptr_t fiobj_obj2num(const FIOBJ obj);
136
139
  FIO_INLINE double fiobj_obj2float(const FIOBJ obj);
137
140
 
138
141
  /**
139
- * Returns a C String (NUL terminated) using the `fio_cstr_s` data type.
142
+ * Returns a C String (NUL terminated) using the `fio_str_info_s` data type.
140
143
  *
141
144
  * The Sting in binary safe and might contain NUL bytes in the middle as well as
142
145
  * a terminating NUL.
@@ -148,13 +151,13 @@ FIO_INLINE double fiobj_obj2float(const FIOBJ obj);
148
151
  *
149
152
  * A type error results in NULL (i.e. object isn't a String).
150
153
  */
151
- FIO_INLINE fio_cstr_s fiobj_obj2cstr(const FIOBJ obj);
154
+ FIO_INLINE fio_str_info_s fiobj_obj2cstr(const FIOBJ obj);
152
155
 
153
156
  /**
154
157
  * Calculates an Objects's SipHash value for possible use as a HashMap key.
155
158
  *
156
159
  * The Object MUST answer to the fiobj_obj2cstr, or the result is unusable. In
157
- * other waords, Hash Objects and Arrays can NOT be used for Hash keys.
160
+ * other words, Hash Objects and Arrays can NOT be used for Hash keys.
158
161
  */
159
162
  FIO_INLINE uint64_t fiobj_obj2hash(const FIOBJ o);
160
163
 
@@ -167,10 +170,8 @@ FIO_INLINE uint64_t fiobj_obj2hash(const FIOBJ o);
167
170
  *
168
171
  * The callback task function must accept an object and an opaque user pointer.
169
172
  *
170
- * Hash objects pass along a `FIOBJ_T_COUPLET` object, containing
171
- * references for both the key and the object. Keys shouldn't be altered once
172
- * placed as a key (or the Hash will break). Collections (Arrays / Hashes) can't
173
- * be used as keeys.
173
+ * Hash objects pass along only the value object. The keys can be accessed using
174
+ * the `fiobj_hash_key_in_loop` function.
174
175
  *
175
176
  * If the callback returns -1, the loop is broken. Any other value is ignored.
176
177
  *
@@ -310,7 +311,7 @@ typedef struct {
310
311
  size_t (*const each)(FIOBJ, size_t start_at, int (*task)(FIOBJ, void *),
311
312
  void *);
312
313
  /* object value as String */
313
- fio_cstr_s (*const to_str)(const FIOBJ);
314
+ fio_str_info_s (*const to_str)(const FIOBJ);
314
315
  /* object value as Integer */
315
316
  intptr_t (*const to_i)(const FIOBJ);
316
317
  /* object value as Float */
@@ -487,13 +488,13 @@ FIO_INLINE intptr_t fiobj_obj2num(const FIOBJ o) {
487
488
  }
488
489
 
489
490
  /** Converts a number to a temporary, thread safe, C string object */
490
- fio_cstr_s fio_ltocstr(long);
491
+ fio_str_info_s fio_ltocstr(long);
491
492
 
492
493
  /** Converts a float to a temporary, thread safe, C string object */
493
- fio_cstr_s fio_ftocstr(double);
494
+ fio_str_info_s fio_ftocstr(double);
494
495
 
495
496
  /**
496
- * Returns a C String (NUL terminated) using the `fio_cstr_s` data type.
497
+ * Returns a C String (NUL terminated) using the `fio_str_info_s` data type.
497
498
  *
498
499
  * The Sting in binary safe and might contain NUL bytes in the middle as well as
499
500
  * a terminating NUL.
@@ -505,9 +506,9 @@ fio_cstr_s fio_ftocstr(double);
505
506
  *
506
507
  * A type error results in NULL (i.e. object isn't a String).
507
508
  */
508
- FIO_INLINE fio_cstr_s fiobj_obj2cstr(const FIOBJ o) {
509
+ FIO_INLINE fio_str_info_s fiobj_obj2cstr(const FIOBJ o) {
509
510
  if (!o) {
510
- fio_cstr_s ret = {{4}, {(void *)"null"}};
511
+ fio_str_info_s ret = {0, 4, (char *)"null"};
511
512
  return ret;
512
513
  }
513
514
  if (o & FIOBJECT_NUMBER_FLAG)
@@ -515,15 +516,15 @@ FIO_INLINE fio_cstr_s fiobj_obj2cstr(const FIOBJ o) {
515
516
  if ((o & FIOBJECT_PRIMITIVE_FLAG) == FIOBJECT_PRIMITIVE_FLAG) {
516
517
  switch ((fiobj_type_enum)o) {
517
518
  case FIOBJ_T_NULL: {
518
- fio_cstr_s ret = {{4}, {(void *)"null"}};
519
+ fio_str_info_s ret = {0, 4, (char *)"null"};
519
520
  return ret;
520
521
  }
521
522
  case FIOBJ_T_FALSE: {
522
- fio_cstr_s ret = {{5}, {(void *)"false"}};
523
+ fio_str_info_s ret = {0, 5, (char *)"false"};
523
524
  return ret;
524
525
  }
525
526
  case FIOBJ_T_TRUE: {
526
- fio_cstr_s ret = {{4}, {(void *)"true"}};
527
+ fio_str_info_s ret = {0, 4, (char *)"true"};
527
528
  return ret;
528
529
  }
529
530
  default:
@@ -539,15 +540,15 @@ uint64_t fiobj_str_hash(FIOBJ o);
539
540
  * Calculates an Objects's SipHash value for possible use as a HashMap key.
540
541
  *
541
542
  * The Object MUST answer to the fiobj_obj2cstr, or the result is unusable. In
542
- * other waords, Hash Objects and Arrays can NOT be used for Hash keys.
543
+ * other words, Hash Objects and Arrays can NOT be used for Hash keys.
543
544
  */
544
545
  FIO_INLINE uint64_t fiobj_obj2hash(const FIOBJ o) {
545
546
  if (FIOBJ_TYPE_IS(o, FIOBJ_T_STRING))
546
547
  return fiobj_str_hash(o);
547
548
  if (!FIOBJ_IS_ALLOCATED(o))
548
549
  return (uint64_t)o;
549
- fio_cstr_s s = fiobj_obj2cstr(o);
550
- return fio_siphash(s.buffer, s.len);
550
+ fio_str_info_s s = fiobj_obj2cstr(o);
551
+ return fio_siphash(s.data, s.len);
551
552
  }
552
553
 
553
554
  /**