void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size)
{
- buf->buf = init;
+ if (init)
+ {
+ buf->buf = init;
+ buf->size = size;
+ } else
+ {
+ buf->buf = buf->static_buf;
+ buf->size = sizeof (buf->static_buf);
+ }
buf->allocated = FcFalse;
buf->failed = FcFalse;
buf->len = 0;
- buf->size = size;
}
void
{
FcChar8 *ret;
- ret = malloc (buf->len + 1);
+ if (buf->failed)
+ ret = NULL;
+ else
+ ret = malloc (buf->len + 1);
if (ret)
{
FcMemAlloc (FC_MEM_STRING, buf->len + 1);
return ret;
}
+FcChar8 *
+FcStrBufDoneStatic (FcStrBuf *buf)
+{
+ FcChar8 *ret;
+
+ FcStrBufChar (buf, '\0');
+
+ if (buf->failed)
+ return NULL;
+
+ return buf->buf;
+}
+
FcBool
FcStrBufChar (FcStrBuf *buf, FcChar8 c)
{
FcChar8 *new;
int size;
+ if (buf->failed)
+ return FcFalse;
+
if (buf->allocated)
{
size = buf->size * 2;
char *dest = str;
char *end = str + len;
char last = 0;
-
+
+ if (*p == '\\')
+ {
+ *p = '/';
+ p++;
+ dest++;
+ }
while (p < end)
{
if (*p == '\\')