This is Unofficial EPICS BASE Doxygen Site
yajl_buf.h File Reference
#include "yajl_common.h"
#include "yajl_alloc.h"
+ Include dependency graph for yajl_buf.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct yajl_buf_tyajl_buf
 

Functions

yajl_buf yajl_buf_alloc (yajl_alloc_funcs *alloc)
 
void yajl_buf_free (yajl_buf buf)
 
void yajl_buf_append (yajl_buf buf, const void *data, size_t len)
 
void yajl_buf_clear (yajl_buf buf)
 
const unsigned char * yajl_buf_data (yajl_buf buf)
 
size_t yajl_buf_len (yajl_buf buf)
 
void yajl_buf_truncate (yajl_buf buf, size_t len)
 

Typedef Documentation

typedef struct yajl_buf_t* yajl_buf

yajl_buf is a buffer with exponential growth. the buffer ensures that you are always null padded.

Definition at line 34 of file yajl_buf.h.

Function Documentation

yajl_buf yajl_buf_alloc ( yajl_alloc_funcs alloc)

Definition at line 56 of file yajl_buf.c.

57 {
58  yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t));
59  if (b == NULL) {
60  return NULL;
61  }
62 
63  memset((void *) b, 0, sizeof(struct yajl_buf_t));
64  b->alloc = alloc;
65  return b;
66 }
#define YA_MALLOC(afs, sz)
Definition: yajl_alloc.h:32
#define NULL
Definition: catime.c:38
yajl_alloc_funcs * alloc
Definition: yajl_buf.c:29
void yajl_buf_append ( yajl_buf  buf,
const void *  data,
size_t  len 
)

Definition at line 75 of file yajl_buf.c.

76 {
77  yajl_buf_ensure_available(buf, len);
78  if (len > 0) {
79  assert(data != NULL);
80  memcpy(buf->data + buf->used, data, len);
81  buf->used += len;
82  buf->data[buf->used] = 0;
83  }
84 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
#define NULL
Definition: catime.c:38
unsigned char * data
Definition: yajl_buf.c:28
size_t used
Definition: yajl_buf.c:27
void yajl_buf_clear ( yajl_buf  buf)

Definition at line 86 of file yajl_buf.c.

87 {
88  buf->used = 0;
89  if (buf->data) buf->data[buf->used] = 0;
90 }
unsigned char * data
Definition: yajl_buf.c:28
size_t used
Definition: yajl_buf.c:27
const unsigned char* yajl_buf_data ( yajl_buf  buf)

Definition at line 92 of file yajl_buf.c.

93 {
94  return buf->data;
95 }
unsigned char * data
Definition: yajl_buf.c:28
void yajl_buf_free ( yajl_buf  buf)

Definition at line 68 of file yajl_buf.c.

69 {
70  assert(buf != NULL);
71  if (buf->data) YA_FREE(buf->alloc, buf->data);
72  YA_FREE(buf->alloc, buf);
73 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
#define YA_FREE(afs, ptr)
Definition: yajl_alloc.h:33
#define NULL
Definition: catime.c:38
unsigned char * data
Definition: yajl_buf.c:28
yajl_alloc_funcs * alloc
Definition: yajl_buf.c:29
size_t yajl_buf_len ( yajl_buf  buf)

Definition at line 97 of file yajl_buf.c.

98 {
99  return buf->used;
100 }
size_t used
Definition: yajl_buf.c:27
void yajl_buf_truncate ( yajl_buf  buf,
size_t  len 
)

Definition at line 103 of file yajl_buf.c.

104 {
105  assert(len <= buf->used);
106  buf->used = len;
107 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
size_t used
Definition: yajl_buf.c:27