#ifndef SMART_POINTERS_H #define SMART_POINTERS_H #include struct smart_pointer { pthread_mutex_t mutex; unsigned nb_ptr; // number of active pointers size_t buffer_size; // size of the buffer void* ptr; // address of the buffer }; /* Initialize a smart pointer */ void init_smart_malloc(struct smart_pointer *sm_ptr, size_t buffer_size); /* create a new active pointer */ void* new_pointer(struct smart_pointer *sm_ptr); /* decrement the number of active pointers, and free the buffer if there are * no more active pointers */ void smart_pointer_free(struct smart_pointer *sm_ptr); #endif /* SMART_POINTERS_H */