X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=kstring.h;h=89a7920c646fd6df2dc773250b7a0f5f1195ccec;hb=df50415f5380510f5b44bee2361413fc39c8bbcf;hp=ec5775b485316c4faaa190a2c501a57fc188985c;hpb=4efe4317c377019fbb64bcfae519403a3a9d1f5f;p=samtools.git diff --git a/kstring.h b/kstring.h index ec5775b..89a7920 100644 --- a/kstring.h +++ b/kstring.h @@ -1,3 +1,28 @@ +/* The MIT License + + Copyright (c) by Attractive Chaos + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + #ifndef KSTRING_H #define KSTRING_H @@ -42,7 +67,16 @@ extern "C" { #ifdef __cplusplus } #endif - + +static inline void ks_resize(kstring_t *s, size_t size) +{ + if (s->m < size) { + s->m = size; + kroundup32(s->m); + s->s = (char*)realloc(s->s, s->m); + } +} + static inline int kputsn(const char *p, int l, kstring_t *s) { if (s->l + l + 1 >= s->m) {