-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.c
More file actions
44 lines (38 loc) · 1.3 KB
/
driver.c
File metadata and controls
44 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "retainCounter.h"
#include "node.h"
#include "stack.h"
#include "baseObject.h"
#include "SomeClass.h"
void deallocateSomeClass(void *inputObject)
{
LSSomeClass *someClass = (LSSomeClass*) inputObject;
printf("Hello from object %p\n", inputObject);
//free(someClass->counter->Deallocate);
free(someClass->counter);
free(someClass);
printf("Hello from object %p\n", inputObject);
}
int main(int argc, char *argv[])
{
LSSomeClass *someClass = LSCreateSomeClass(5);
someClass->counter->Deallocate = deallocateSomeClass;
LSStack *myStack = LSStackCreate();
LSPush(myStack, (LSBaseObject*)someClass);
printf("Stack top: %d\n", (myStack->top->counter->retainCount));
printf("Object: %d\n", someClass->counter->retainCount);
LSRetain(myStack->top);
printf("After Retain\n");
printf("Stack top: %d\n", (myStack->top->counter->retainCount));
//LSPush(myStack, (LSBaseObject*)LSCreateSomeClass(10));
//LSPop(myStack);
//LSPop(myStack);
LSRelease(someClass);
//LSRelease(someClass);
printf("Stack top: %p\n", (myStack->top->value));
printf("SomeClass retain count: %d\n", someClass->counter->retainCount);
printf("SomeClass value: %d\n", someClass->value);
return 0;
}