MCPcopy Create free account
hub / github.com/arq5x/bedtools2 / string_alloc

Function string_alloc

src/utils/htslib/cram/string_alloc.c:110–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108/* allocate space for a string */
109
110char *string_alloc(string_alloc_t *a_str, size_t length) {
111 string_t *str;
112 char *ret;
113
114 if (length <= 0) return NULL;
115
116 // add to last string pool if we have space
117 if (a_str->nstrings) {
118 str = &a_str->strings[a_str->nstrings - 1];
119
120 if (str->used + length < a_str->max_length) {
121 ret = str->str + str->used;
122 str->used += length;
123 return ret;
124 }
125 }
126
127 // increase the max length if needs be
128 if (length > a_str->max_length) a_str->max_length = length;
129
130 // need a new string pool
131 str = new_string_pool(a_str);
132
133 if (NULL == str) return NULL;
134
135 str->used = length;
136 return str->str;
137}
138
139
140/* equivalent to strdup */

Callers 1

string_ndupFunction · 0.85

Calls 1

new_string_poolFunction · 0.85

Tested by

no test coverage detected