/** 
 * More aggressive way of getting private vars.  In this case,
 * users cannot read or chaneg the value. They can change the 
 * pointer, but this is on them
 * 
 * *author gtowell
 * Created April 21, 2021
 * **/
#include <stdio.h>
#include <stdlib.h>
#ifndef NULL
#define NULL (void *)0
#endif

typedef struct {
    void* private1;
} privOI;
/**
 * Get the value from the private structure
 * This will die if a value has never beeen set
 * @param pn the structure to read from
 * @return the value
 * **/
int getYear(privOI* pn) {
    int *ip = pn->private1;
    return *ip;
}
/** 
 * Set the value
 * Allocates memory if the value was never before set
 * @param pn the structure hoilding the value
 * @param -- the value to be set
 * **/
void setYear(privOI* pn, int yr) {
    if (pn->private1 == NULL) {
        pn->private1 = malloc(1 * sizeof(int));
    }
    int *ip = pn->private1;
    *ip = yr;
}
/**
 * onstructor
 * **/
privOI* makePrivOI() {
    privOI* poi = malloc(1 * sizeof(privOI));
}
int main(int argc, char const *argv[]) {
    privOI *pn = makePrivOI();
    setYear(pn, 1961);
    printf("%d\n", getYear(pn));
    return 0;
}