Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid conflicting with HTSlib's kstring.c functions #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions kstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
# include "malloc_wrap.h"
#endif

int ksprintf(kstring_t *s, const char *fmt, ...)
int bwa_kvsprintf(kstring_t *s, const char *fmt, va_list ap)
{
va_list ap;
va_list ap2;
int l;
va_start(ap, fmt);
va_copy(ap2, ap);
l = vsnprintf(s->s + s->l, s->m - s->l, fmt, ap);
va_end(ap);
if (l + 1 > s->m - s->l) {
s->m = s->l + l + 2;
kroundup32(s->m);
s->s = (char*)realloc(s->s, s->m);
va_start(ap, fmt);
l = vsnprintf(s->s + s->l, s->m - s->l, fmt, ap);
l = vsnprintf(s->s + s->l, s->m - s->l, fmt, ap2);
}
va_end(ap);
va_end(ap2);
s->l += l;
return l;
}
Expand Down
18 changes: 17 additions & 1 deletion kstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#ifdef USE_MALLOC_WRAPPERS
# include "malloc_wrap.h"
Expand Down Expand Up @@ -110,6 +111,21 @@ static inline int kputl(long c, kstring_t *s)
return 0;
}

int ksprintf(kstring_t *s, const char *fmt, ...);
int bwa_kvsprintf(kstring_t *s, const char *fmt, va_list ap);

static inline int ksprintf(kstring_t *s, const char *fmt, ...)
{
va_list ap;
int l;
va_start(ap, fmt);
l = bwa_kvsprintf(s, fmt, ap);
va_end(ap);
return l;
}

static inline int kvsprintf(kstring_t *s, const char *fmt, va_list ap)
{
return bwa_kvsprintf(s, fmt, ap);
}

#endif