process.c 801 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <stdint.h>
  2. #include <stddef.h>
  3. #include <stdbool.h>
  4. #include "models.h"
  5. #include "status.h"
  6. #include "process.h"
  7. #ifndef ZIVUOS_USE_STATIC
  8. #include <malloc.h>
  9. #endif
  10. #ifndef ZIVUOS_USE_STATIC
  11. zv_process_t * zv_process_create() {
  12. zv_process_t *self = (zv_process_t *) malloc(sizeof(zv_process_t));
  13. if (self == NULL) {
  14. return NULL;
  15. }
  16. self->is_dynamic = true;
  17. self->status = ZV_STATUS_CREATING;
  18. self->next = NULL;
  19. return self;
  20. }
  21. zv_process_t * zv_process_remove(zv_process_t *self) {
  22. zv_process_t *next = self->next;
  23. if (self->is_dynamic) {
  24. free(self);
  25. }
  26. return next;
  27. }
  28. #else
  29. zv_process_t * zv_process_create() {
  30. return NULL;
  31. }
  32. zv_process_t * zv_process_remove(zv_process_t *self) {
  33. return self->next;
  34. }
  35. #endif