| 60 | #define INIT_SIZE 16 |
| 61 | |
| 62 | static int |
| 63 | _append_char(_tmp_string_t *s, char c) |
| 64 | { |
| 65 | if (s->pos >= s->allocated) { |
| 66 | char *p; |
| 67 | size_t to_alloc = (s->allocated == 0) ? INIT_SIZE : (2 * s->allocated); |
| 68 | |
| 69 | p = PyObject_Realloc(s->s, to_alloc); |
| 70 | if (p == NULL) { |
| 71 | PyErr_SetString(PyExc_MemoryError, "memory allocation failed"); |
| 72 | return -1; |
| 73 | } |
| 74 | s->s = p; |
| 75 | s->allocated = to_alloc; |
| 76 | } |
| 77 | s->s[s->pos] = c; |
| 78 | ++s->pos; |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | static int |
| 83 | _append_str(_tmp_string_t *s, char const *p) |
no outgoing calls
no test coverage detected