]> git.donarmstrong.com Git - samtools.git/blobdiff - kstring.h
converted padded SAM to unpadded SAM
[samtools.git] / kstring.h
index ec5775b485316c4faaa190a2c501a57fc188985c..89a7920c646fd6df2dc773250b7a0f5f1195ccec 100644 (file)
--- a/kstring.h
+++ b/kstring.h
@@ -1,3 +1,28 @@
+/* The MIT License
+
+   Copyright (c) by Attractive Chaos <attractor@live.co.uk> 
+
+   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) {