81bf78b39d3b82f8ffd123f796ae5e6f5228af4c
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c  1) #include "cleaner.h"
liblwpttr/src/cleaner.c  2) #include "macros.h"
liblwpttr/src/cleaner.c  3) 
liblwpttr/src/cleaner.c  4) #include <stdlib.h>
liblwpttr/src/cleaner.c  5) 
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c  6) struct lwptev_cleaner_s {
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c  7)   unsigned int free_ptr_cnt; /**< number of pointer to be freed */
liblwpttr/src/cleaner.c  8)   void * free_ptrs[64]; /**< pointers to be freed */
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c  9)   lwptev_cleaner_t *next; /**< next cleaner object, linked list */
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 10) };
liblwpttr/src/cleaner.c 11) 
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c 12) lwptev_cleaner_t * lwptev_cleaner_new(void) {
liblwptev/src/cleaner.c 13)   lwptev_cleaner_t *cleaner = malloc(sizeof(lwptev_cleaner_t));
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 14)   if (! cleaner) {
liblwpttr/src/cleaner.c 15)     return NULL;
liblwpttr/src/cleaner.c 16)   }
liblwpttr/src/cleaner.c 17)   cleaner->free_ptr_cnt = 0;
liblwpttr/src/cleaner.c 18)   cleaner->next = NULL;
liblwpttr/src/cleaner.c 19)   return cleaner;
liblwpttr/src/cleaner.c 20) }
liblwpttr/src/cleaner.c 21) 
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c 22) int lwptev_cleaner_add_ptr(lwptev_cleaner_t *cleaner, void *ptr) {
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 23)   /* find last cleaner in chain */
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c 24)   lwptev_cleaner_t *cl = cleaner;
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 25)   while (cl->next != NULL) {
liblwpttr/src/cleaner.c 26)     cl = cl->next;
liblwpttr/src/cleaner.c 27)   }
liblwpttr/src/cleaner.c 28)   /* last cleaner full? */
liblwpttr/src/cleaner.c 29)   if (cl->free_ptr_cnt >= countof(cl->free_ptrs)) {
liblwpttr/src/cleaner.c 30)     /* create new one */
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c 31)     cl->next = lwptev_cleaner_new();
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 32)     /* error ? */
liblwpttr/src/cleaner.c 33)     if (! cl->next) {
liblwpttr/src/cleaner.c 34)       /* cleanup everything and reutrn error */
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c 35)       lwptev_cleaner_cleanup(cleaner);
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 36)       return -1;
liblwpttr/src/cleaner.c 37)     }
liblwpttr/src/cleaner.c 38)     /* go to new cleaner */
liblwpttr/src/cleaner.c 39)     cl = cl->next;
liblwpttr/src/cleaner.c 40)   }
liblwpttr/src/cleaner.c 41)   /* add pointer */
liblwpttr/src/cleaner.c 42)   cl->free_ptrs[cl->free_ptr_cnt++] = ptr;
liblwpttr/src/cleaner.c 43)   return 0;
liblwpttr/src/cleaner.c 44) }
liblwpttr/src/cleaner.c 45) 
Stefan Schuermans lwpttr -> lwptev

Stefan Schuermans authored 4 years ago

liblwptev/src/cleaner.c 46) void lwptev_cleaner_cleanup(lwptev_cleaner_t *cleaner) {
liblwptev/src/cleaner.c 47)   lwptev_cleaner_t *cl = cleaner;