aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicolas Dato <nicolas.dato@gmail.com>2025-07-02 23:41:29 -0300
committerNicolas Dato <nicolas.dato@gmail.com>2025-07-02 23:41:29 -0300
commit4c15b4e3459311f8d458e0e9c031a473efe5f0b8 (patch)
treebad582b89b713a68b48eb7fc9a01c03adcdf7fe7 /src
parent2ce4fb4a3cfb0d1cb92e9cbd71087fa16414631e (diff)
downloadlibtuberia-4c15b4e3459311f8d458e0e9c031a473efe5f0b8.tar.gz
adding an example, without using libtuberia for now
Diffstat (limited to 'src')
-rw-r--r--src/itc.c8
-rw-r--r--src/tuberia.c4
-rw-r--r--src/utils.c2
-rw-r--r--src/utils.h2
4 files changed, 8 insertions, 8 deletions
diff --git a/src/itc.c b/src/itc.c
index c47e538..6dc3d41 100644
--- a/src/itc.c
+++ b/src/itc.c
@@ -24,7 +24,7 @@ itc *itc_alloc(int nslots)
ctx = calloc(1, sizeof(*ctx));
ctx->nslots = nslots;
- ctx->slots = calloc(nslots, sizeof(*ctx->slots));
+ ctx->slots = (void **)calloc(nslots, sizeof(*ctx->slots));
sem_init(&ctx->emptied, 0, nslots);
sem_init(&ctx->occupied, 0, 0);
@@ -41,7 +41,7 @@ void itc_free(itc **ctx, itc_free_element free_element)
sem_destroy(&(*ctx)->emptied);
sem_destroy(&(*ctx)->occupied);
- free((*ctx)->slots);
+ free((void *)(*ctx)->slots);
free(*ctx);
*ctx = NULL;
}
@@ -55,7 +55,7 @@ void *itc_retrive(itc *ctx, int timeout_ms)
return NULL;
}
- timespec_add_ms(gettimespec(&ts), timeout_ms);
+ timespec_add_ms(get_timespec(&ts), timeout_ms);
if (sem_timedwait(&ctx->occupied, &ts)) {
return NULL;
@@ -75,7 +75,7 @@ int itc_inject(itc *ctx, int timeout_ms, void *element)
return -1;
}
- timespec_add_ms(gettimespec(&ts), timeout_ms);
+ timespec_add_ms(get_timespec(&ts), timeout_ms);
if (sem_timedwait(&ctx->emptied, &ts)) {
return -1;
diff --git a/src/tuberia.c b/src/tuberia.c
index d8b5688..d9af3c8 100644
--- a/src/tuberia.c
+++ b/src/tuberia.c
@@ -148,8 +148,8 @@ tube *tube_alloc(const tube_source *source, tube_sink sink, void *opaque)
for (ctx->nitcs = 1, s = source->next; s != NULL; ctx->nitcs++) {
s = s->next;
}
- ctx->itcs = calloc(ctx->nitcs, sizeof(itc *));
- ctx->free_element = calloc(ctx->nitcs, sizeof(tube_free_element));
+ ctx->itcs = (struct itc **)calloc(ctx->nitcs, sizeof(itc *));
+ ctx->free_element = (tube_free_element *)calloc(ctx->nitcs, sizeof(tube_free_element));
ctx->itcs[0] = itc_alloc(source->nslots);
ctx->free_element[0] = source->free_element;
for (i = 1, s = source->next; s != NULL; s = s->next, i++) {
diff --git a/src/utils.c b/src/utils.c
index 6b2ff46..23adc5c 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -18,7 +18,7 @@ struct timespec *timespec_add_ms(struct timespec *ts, int timeout_ms)
return ts;
}
-struct timespec *gettimespec(struct timespec *ts)
+struct timespec *get_timespec(struct timespec *ts)
{
struct timeval tv;
diff --git a/src/utils.h b/src/utils.h
index 0fde429..d72cc00 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -4,7 +4,7 @@
#include <sys/time.h>
struct timespec *timespec_add_ms(struct timespec *ts, int timeout_ms);
-struct timespec *gettimespec(struct timespec *ts);
+struct timespec *get_timespec(struct timespec *ts);
#endif //LIBTUBERIA_UTILS_H__