840c0b18e9990fe15416283f869bc8532c1bbf3a
Stefan Schuermans add copyright headers and l...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c   1) /**
libuptev/src/cleaner.c   2)  * UProcTrace: User-space Process Tracing
libuptev/src/cleaner.c   3)  * Copyright 2020: Stefan Schuermans, Aachen, Germany <stefan@schuermans.info>
libuptev/src/cleaner.c   4)  * Copyleft: GNU LESSER GENERAL PUBLIC LICENSE version 3 (see LICENSE)
libuptev/src/cleaner.c   5)  */
libuptev/src/cleaner.c   6) 
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c  7) #include "cleaner.h"
liblwpttr/src/cleaner.c  8) #include "macros.h"
liblwpttr/src/cleaner.c  9) 
liblwpttr/src/cleaner.c 10) #include <stdlib.h>
liblwpttr/src/cleaner.c 11) 
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  12) struct uptev_cleaner_s {
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 13)   unsigned int free_ptr_cnt; /**< number of pointer to be freed */
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  14)   void *free_ptrs[64];       /**< pointers to be freed */
libuptev/src/cleaner.c  15)   uptev_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 16) };
liblwpttr/src/cleaner.c 17) 
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  18) uptev_cleaner_t *uptev_cleaner_new(void) {
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  19)   uptev_cleaner_t *cleaner = malloc(sizeof(uptev_cleaner_t));
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  20)   if (!cleaner) {
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 21)     return NULL;
liblwpttr/src/cleaner.c 22)   }
liblwpttr/src/cleaner.c 23)   cleaner->free_ptr_cnt = 0;
liblwpttr/src/cleaner.c 24)   cleaner->next = NULL;
liblwpttr/src/cleaner.c 25)   return cleaner;
liblwpttr/src/cleaner.c 26) }
liblwpttr/src/cleaner.c 27) 
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  28) int uptev_cleaner_add_ptr(uptev_cleaner_t *cleaner, void *ptr) {
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 29)   /* find last cleaner in chain */
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  30)   uptev_cleaner_t *cl = cleaner;
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 31)   while (cl->next != NULL) {
liblwpttr/src/cleaner.c 32)     cl = cl->next;
liblwpttr/src/cleaner.c 33)   }
liblwpttr/src/cleaner.c 34)   /* last cleaner full? */
liblwpttr/src/cleaner.c 35)   if (cl->free_ptr_cnt >= countof(cl->free_ptrs)) {
liblwpttr/src/cleaner.c 36)     /* create new one */
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  37)     cl->next = uptev_cleaner_new();
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 38)     /* error ? */
Stefan Schuermans formatting

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  39)     if (!cl->next) {
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 40)       /* cleanup everything and reutrn error */
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  41)       uptev_cleaner_cleanup(cleaner);
Stefan Schuermans add exe and cwd to proc_begin

Stefan Schuermans authored 4 years ago

liblwpttr/src/cleaner.c 42)       return -1;
liblwpttr/src/cleaner.c 43)     }
liblwpttr/src/cleaner.c 44)     /* go to new cleaner */
liblwpttr/src/cleaner.c 45)     cl = cl->next;
liblwpttr/src/cleaner.c 46)   }
liblwpttr/src/cleaner.c 47)   /* add pointer */
liblwpttr/src/cleaner.c 48)   cl->free_ptrs[cl->free_ptr_cnt++] = ptr;
liblwpttr/src/cleaner.c 49)   return 0;
liblwpttr/src/cleaner.c 50) }
liblwpttr/src/cleaner.c 51) 
Stefan Schuermans rename: lwproctrace -> upro...

Stefan Schuermans authored 4 years ago

libuptev/src/cleaner.c  52) void uptev_cleaner_cleanup(uptev_cleaner_t *cleaner) {
libuptev/src/cleaner.c  53)   uptev_cleaner_t *cl = cleaner;