summaryrefslogtreecommitdiff
path: root/src/chunk.h
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-12 17:48:03 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2014-11-12 19:31:41 +0100
commite9ba8f064cb61239be6432ec60ab2ced3d9d339f (patch)
tree3b7e2fe79f4f069fcc904f71b560e847a9a8a1e8 /src/chunk.h
parentfc923ee0a3e3837fdb51c3f8fc6e99d16bdb8f4c (diff)
Prefix names in chunk.h
Diffstat (limited to 'src/chunk.h')
-rw-r--r--src/chunk.h43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/chunk.h b/src/chunk.h
index 208880a..e4a57b2 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -11,9 +11,9 @@ typedef struct {
const unsigned char *data;
int len;
int alloc;
-} chunk;
+} cmark_chunk;
-static inline void chunk_free(chunk *c)
+static inline void cmark_chunk_free(cmark_chunk *c)
{
if (c->alloc)
free((char *)c->data);
@@ -23,7 +23,7 @@ static inline void chunk_free(chunk *c)
c->len = 0;
}
-static inline void chunk_ltrim(chunk *c)
+static inline void cmark_chunk_ltrim(cmark_chunk *c)
{
assert(!c->alloc);
@@ -33,7 +33,7 @@ static inline void chunk_ltrim(chunk *c)
}
}
-static inline void chunk_rtrim(chunk *c)
+static inline void cmark_chunk_rtrim(cmark_chunk *c)
{
while (c->len > 0) {
if (!isspace(c->data[c->len - 1]))
@@ -43,19 +43,19 @@ static inline void chunk_rtrim(chunk *c)
}
}
-static inline void chunk_trim(chunk *c)
+static inline void cmark_chunk_trim(cmark_chunk *c)
{
- chunk_ltrim(c);
- chunk_rtrim(c);
+ cmark_chunk_ltrim(c);
+ cmark_chunk_rtrim(c);
}
-static inline int chunk_strchr(chunk *ch, int c, int offset)
+static inline int cmark_chunk_strchr(cmark_chunk *ch, int c, int offset)
{
const unsigned char *p = memchr(ch->data + offset, c, ch->len - offset);
return p ? (int)(p - ch->data) : ch->len;
}
-static inline unsigned char *chunk_to_cstr(chunk *c)
+static inline unsigned char *cmark_chunk_to_cstr(cmark_chunk *c)
{
unsigned char *str;
@@ -67,21 +67,21 @@ static inline unsigned char *chunk_to_cstr(chunk *c)
return str;
}
-static inline chunk chunk_literal(const char *data)
+static inline cmark_chunk cmark_chunk_literal(const char *data)
{
- chunk c = {(const unsigned char *)data, data ? strlen(data) : 0, 0};
+ cmark_chunk c = {(const unsigned char *)data, data ? strlen(data) : 0, 0};
return c;
}
-static inline chunk chunk_dup(const chunk *ch, int pos, int len)
+static inline cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, int pos, int len)
{
- chunk c = {ch->data + pos, len, 0};
+ cmark_chunk c = {ch->data + pos, len, 0};
return c;
}
-static inline chunk chunk_buf_detach(cmark_strbuf *buf)
+static inline cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf)
{
- chunk c;
+ cmark_chunk c;
c.len = buf->size;
c.data = cmark_strbuf_detach(buf);
@@ -90,4 +90,17 @@ static inline chunk chunk_buf_detach(cmark_strbuf *buf)
return c;
}
+#ifndef CMARK_NO_SHORT_NAMES
+ #define chunk cmark_chunk
+ #define chunk_free cmark_chunk_free
+ #define chunk_ltrim cmark_chunk_ltrim
+ #define chunk_rtrim cmark_chunk_rtrim
+ #define chunk_trim cmark_chunk_trim
+ #define chunk_strchr cmark_chunk_strchr
+ #define chunk_to_cstr cmark_chunk_to_cstr
+ #define chunk_literal cmark_chunk_literal
+ #define chunk_dup cmark_chunk_dup
+ #define chunk_buf_detach cmark_chunk_buf_detach
+#endif
+
#endif