2 extern int classsize[];
4 plistnode_t *pCreate(int objects) {
7 //Create main structure
8 if((pile = calloc(1, sizeof(plistnode_t))) == NULL) {
9 printf("Calloc error %s %d\n", __FILE__, __LINE__);
13 if ((pile->oidmod = calloc(objects, sizeof(unsigned int))) == NULL) {
14 printf("Calloc error %s %d\n", __FILE__, __LINE__);
17 if ((pile->oidread = calloc(objects, sizeof(unsigned int))) == NULL) {
18 printf("Calloc error %s %d\n", __FILE__, __LINE__);
21 pile->nummod = pile->numread = pile->sum_bytes = 0;
22 if ((pile->objread = calloc(objects, sizeof(int) + sizeof(short))) == NULL) {
23 printf("Calloc error %s %d\n", __FILE__, __LINE__);
26 pile->objmodified = NULL;
27 pile->nummod = pile->numread = pile->sum_bytes = 0;
32 plistnode_t *pInsert(plistnode_t *pile, objheader_t *headeraddr, unsigned int mid, int num_objs) {
33 plistnode_t *ptr, *tmp;
34 int found = 0, offset;
37 //Add oid into a machine that is a part of the pile linked list structure
39 if (tmp->mid == mid) {
40 if ((headeraddr->status >> 1) == 1) {
41 tmp->oidmod[tmp->nummod] = headeraddr->oid;
42 tmp->nummod = tmp->nummod + 1;
43 tmp->sum_bytes += sizeof(objheader_t) + classsize[headeraddr->type];
45 tmp->oidread[tmp->numread] = headeraddr->oid;
46 offset = (sizeof(unsigned int) + sizeof(short)) * tmp->numread;
47 memcpy(tmp->objread, &headeraddr->oid, sizeof(unsigned int));
48 offset += sizeof(unsigned int);
49 memcpy(tmp->objread + offset, &headeraddr->version, sizeof(short));
50 tmp->numread = tmp->numread + 1;
57 //Add oid for any new machine
59 if((ptr = pCreate(num_objs)) == NULL) {
63 if ((headeraddr->status >> 1) == 1) {
64 ptr->oidmod[ptr->nummod] = headeraddr->oid;
65 ptr->nummod = ptr->nummod + 1;
66 ptr->sum_bytes += sizeof(objheader_t) + classsize[headeraddr->type];
68 ptr->oidread[ptr->numread] = headeraddr->oid;
69 memcpy(ptr->objread, &headeraddr->oid, sizeof(unsigned int));
70 memcpy(ptr->objread + sizeof(unsigned int), &headeraddr->version, sizeof(short));
71 ptr->numread = ptr->numread + 1;
79 //Count the number of machine groups
80 int pCount(plistnode_t *pile) {
91 //Make a list of mid's for each machine group
92 int pListMid(plistnode_t *pile, unsigned int *list) {
104 //Delete the entire pile
105 void pDelete(plistnode_t *pile) {
106 plistnode_t *next, *tmp;