| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "pipe.h"
- #ifndef STATIC_ONLY
- #include <malloc.h>
- #endif
- zv_pipe_t * zv_pipe_create() {
- #ifdef STATIC_ONLY
- return (zv_pipe_t *) NULL;
- #else
- zv_pipe_t *self = (zv_pipe_t *) malloc(sizeof(zv_pipe_t));
- if (self == NULL) {
- return self;
- }
- zv_pipe_init(self);
- return self;
- #endif
- }
- void zv_pipe_init(zv_pipe_t *self) {
- self->content = (zv_pipe_t *) NULL;
- self->changed = false;
- }
- void zv_pipe_delete(zv_pipe_t *self) {
- #ifndef STATIC_ONLY
- if (self != NULL) {
- free(self);
- }
- #endif
- }
- bool zv_pipe_is_changed(zv_pipe_t *self) {
- return self->changed;
- }
- intptr_t zv_pipe_read_number(zv_pipe_t *self) {
- self->changed = false;
- return (intptr_t) self->content;
- }
- void * zv_pipe_read_content(zv_pipe_t *self) {
- self->changed = false;
- return self->content;
- }
- void zv_pipe_write_number(zv_pipe_t *self, intptr_t content) {
- self->changed = true;
- self->content = (void *) content;
- }
- void zv_pipe_write_content(zv_pipe_t *self, void *content) {
- self->changed = true;
- self->content = content;
- }
|