1 #include "machinepile.h"
3 prefetchpile_t *insertPile(int mid, unsigned int oid, short numoffset, short *offset, prefetchpile_t *head) {
4 prefetchpile_t *tmp = head;
7 unsigned int *oidarray;
13 if (tmp->mid == mid) { // Found a match with exsisting machine id
14 if ((objnode = (objpile_t *) calloc(1, sizeof(objpile_t))) == NULL) {
15 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
18 if ((offvalues = (short *) calloc(numoffset, sizeof(short))) == NULL) {
19 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
22 /* Fill objpiles DS */
24 objnode->numoffset = numoffset;
25 for(i = 0; i<numoffset; i++)
26 offvalues[i] = offset[i];
27 objnode->offset = offvalues;
28 objnode->next = tmp->objpiles;
29 tmp->objpiles = objnode;
38 if(tmp->mid == 0) {//First time
40 if ((objnode = (objpile_t *) calloc(1, sizeof(objpile_t))) == NULL) {
41 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
44 if ((offvalues = (short *) calloc(numoffset, sizeof(short))) == NULL) {
45 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
50 objnode->numoffset = numoffset;
51 for(i = 0; i<numoffset; i++)
52 offvalues[i] = *((short *)offset + i);
53 objnode->offset = offvalues;
55 tmp->objpiles = objnode;
58 if ((tmp = (prefetchpile_t *) calloc(1, sizeof(prefetchpile_t))) == NULL) {
59 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
63 if ((objnode = (objpile_t *) calloc(1, sizeof(objpile_t))) == NULL) {
64 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
67 if ((offvalues = (short *) calloc(numoffset, sizeof(short))) == NULL) {
68 printf("Calloc error: %s %d\n", __FILE__, __LINE__);
73 objnode->numoffset = numoffset;
74 for(i = 0; i<numoffset; i++)
75 offvalues[i] = *((short *)offset + i);
76 objnode->offset = offvalues;
78 tmp->objpiles = objnode;