3 obj_store_t *obj_begin;
4 obj_listnode_t *obj_lnode_begin;
6 extern int classsize[];
8 /* BEGIN - object store */
10 void dstm_init(void) {
12 obj_lnode_begin = NULL;
16 void create_objstr(unsigned int size) {
17 obj_store_t *tmp, *ptr;
20 if ((tmp = (obj_store_t *) malloc(sizeof(obj_store_t))) < 0) {
21 printf("DSTM: Malloc error %s %d\n", __FILE__, __LINE__);
24 if ((tmp->base = (char *) malloc(sizeof(char)*size)) < 0) {
25 printf("DSTM: Malloc error %s %d\n", __FILE__, __LINE__);
31 if (obj_begin == NULL) { // First entry
34 } else { // Insert to the front of the linked list
35 tmp->next = obj_begin;
41 void delete_objstr(int id) {
42 //TODO Implement this along with garbage collector
46 obj_store_t *get_objstr_begin(void) {
50 /* END object store */
52 /* BEGIN object header */
59 int insertObject(obj_header_t h) {
62 left = obj_begin->size - (obj_begin->top - obj_begin->base);
63 req = getObjSize(h) + sizeof(obj_header_t);
65 memcpy(obj_begin->top, &h, sizeof(obj_header_t));
66 obj_begin->top = obj_begin->top + sizeof(obj_header_t) + getObjSize(h);
70 //TODO Update obj_addr_table
74 int getObjSize(obj_header_t h) {
75 return classsize[h.type];
78 void createObject(unsigned short type) {
88 /* END object header */
90 /* BEGIN obj_listnode */
92 int IsEmpty(obj_listnode_t *node) {
93 return obj_lnode_begin == NULL;
96 void insert_lnode(obj_listnode_t *node) {
97 if(obj_lnode_begin == NULL) { // Enter "node" as the first node in linked list
98 obj_lnode_begin = node;
100 } else { // Enter "node" to the beginning of the linked list
101 node->next = obj_lnode_begin;
102 obj_lnode_begin = node ;
108 int delete_lnode(obj_listnode_t *node, unsigned int oid) {
109 obj_listnode_t pre, curr;
110 if( obj_lnode_begin == NULL){
111 printf(" No nodes to delete ");
115 pre = curr = obj_lnode_begin;
116 while(node->next != NULL) {
119 if(oid == node->oid){
125 /* END obj_listnode */