libstr-c

C string library
git clone https://git.sinitax.com/sinitax/libstr-c
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

str.h (1105B)


      1#pragma once
      2
      3#include "allocator.h"
      4
      5#ifdef LIBSTR_ASSERT_ARGS
      6#include "stdlib.h"
      7#define LIBSTR_ABORT_ON_ARGS(cond) do { if (cond) abort(); } while (0)
      8#else
      9#define LIBSTR_ABORT_ON_ARGS(cond)
     10#endif
     11
     12#ifdef LIBSTR_ASSERT_ALLOC
     13#include "stdlib.h"
     14#define LIBSTR_ABORT_ON_ALLOC(cond) do { if (cond) abort(); } while (0)
     15#else
     16#define LIBSTR_ABORT_ON_ALLOC(cond)
     17#endif
     18
     19char * __attribute__((format(printf, 3, 4)))
     20str_fmt(const struct allocator *allocator, int *rc,
     21	const char *fmstr, ...);
     22char * __attribute__((format(printf, 4, 5)))
     23str_fmt_realloc(const struct allocator *allocator, int *rc,
     24	void *alloc, const char *fmtstr, ...);
     25
     26char *str_dup(const struct allocator *allocator, int *rc,
     27	const char *str);
     28char *str_dup_realloc(const struct allocator *allocator, int *rc,
     29	void *alloc, const char *str);
     30
     31char *str_ndup(const struct allocator *allocator, int *rc,
     32	const char *str, size_t n);
     33char *str_ndup_realloc(const struct allocator *allocator, int *rc,
     34	void *alloc, const char *str, size_t n);
     35
     36char *str_app(const struct allocator *allocator, int *rc,
     37	char *str, const char *app);
     38