diff options
author | Timo Dritschler <timo.dritschler@kit.edu> | 2014-06-06 18:31:40 +0200 |
---|---|---|
committer | Timo Dritschler <timo.dritschler@kit.edu> | 2014-06-06 18:31:40 +0200 |
commit | ca46d010c312e804ee79265236301f02a606123f (patch) | |
tree | 91d798cb5e5ce397758beaa9b8178f3f026480ba /src/kiro-trb.c | |
parent | 1272ee769caed1298b9d26b9f8e74a12b2d7c355 (diff) | |
download | kiro-ca46d010c312e804ee79265236301f02a606123f.tar.gz kiro-ca46d010c312e804ee79265236301f02a606123f.tar.bz2 kiro-ca46d010c312e804ee79265236301f02a606123f.tar.xz kiro-ca46d010c312e804ee79265236301f02a606123f.zip |
Updated documentation to make it conform with Gtk Documentation-Guide
Added kiro_trb_purge to completely reset the entire buffer
Diffstat (limited to 'src/kiro-trb.c')
-rw-r--r-- | src/kiro-trb.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/kiro-trb.c b/src/kiro-trb.c index e81a4f7..dc8146f 100644 --- a/src/kiro-trb.c +++ b/src/kiro-trb.c @@ -167,6 +167,22 @@ void kiro_trb_flush (KiroTrb *self) } +void kiro_trb_purge (KiroTrb* self, gboolean free_memory) +{ + KiroTrbPrivate *priv = KIRO_TRB_GET_PRIVATE(self); + priv->iteration = 0; + priv->current = NULL; + priv->initialized = 0; + priv->max_elements = 0; + priv->buff_size = 0; + priv->frame_top = NULL; + priv->element_size = 0; + if(free_memory) + free(priv->mem); + priv->mem = NULL; +} + + int kiro_trb_is_setup (KiroTrb *self) { KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self); @@ -176,6 +192,8 @@ int kiro_trb_is_setup (KiroTrb *self) int kiro_trb_reshape (KiroTrb *self, uint64_t element_size, uint64_t element_count) { + if(element_size < 1 || element_count < 1) + return -1; size_t new_size = (element_size * element_count) + sizeof(struct KiroTrbInfo); void* newmem = malloc(new_size); if(!newmem) @@ -244,6 +262,8 @@ void kiro_trb_refresh (KiroTrb *self) void kiro_trb_adopt (KiroTrb *self, void *buff_in) { + if(!buff_in) + return; KiroTrbPrivate* priv = KIRO_TRB_GET_PRIVATE(self); if(priv->mem) free(priv->mem); |