Exemplo n.º 1
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0;
	PUT_INT(enabled); pos+=4;
  PUT_INT(color_clip); pos+=4;
	return pos;
}
Exemplo n.º 2
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0;
  PUT_INT(dir); pos+=4;
  PUT_INT(which); pos+=4;
  PUT_INT(blend); pos+=4;
  PUT_INT(adjblend_val); pos+=4;
	return pos;
}
Exemplo n.º 3
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0,x=0;
	PUT_INT(effect); pos+=4;
	PUT_INT(num_colors); pos+=4;
  while (x < num_colors) { PUT_INT(colors[x]); x++;  pos+=4; }
	PUT_INT(size); pos+=4;
	PUT_INT(rot); pos+=4;
	return pos;
}
Exemplo n.º 4
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0;
  data[pos++]=1;
  save_string(data,pos,effect_exp[0]);
  save_string(data,pos,effect_exp[1]);
  save_string(data,pos,effect_exp[2]);
	PUT_INT(blend); pos+=4;
	PUT_INT(subpixel); pos+=4;
	return pos;
}
Exemplo n.º 5
0
/* put header, footer and free_list pointers in a free block */
void free_ptr(void *ptr, void *prev, void *next, unsigned size)
{
    unsigned header = PACK(size, 0);
    // header
    PUT_INT(HDRP(ptr), header);
    // footer
    PUT_INT(FTRP(ptr), header);
    // prev and next
    PUT(PREV_PTR(ptr), prev);
    PUT(NEXT_PTR(ptr), next);
}
Exemplo n.º 6
0
long SDMCode::Marshal(char* buf)
{
    int cur;
    cur = HEADER_SIZE;
    PUT_USHORT(&buf[cur], seq_num);
    cur += sizeof(seq_num);
    PUT_USHORT(&buf[cur], num_segments);
    cur += sizeof(num_segments);
    //
    // Copy the filename
    size_t uiCurLength = strlen(filename);
    strcpy(buf + cur, filename);
    cur += (int)uiCurLength + 1;
    //
    // Copy the code section
    memcpy (&buf[cur], &code, code_length);
    cur += code_length;

    c_sum = checksum(code, code_length);
    PUT_INT (&buf[cur], c_sum);
    cur += sizeof (c_sum);
    msg_length = cur - HEADER_SIZE;
    MarshalHeader(buf);
    return cur;
}
Exemplo n.º 7
0
/*
 * mm_realloc - Implemented simply in terms of mm_malloc and mm_free,
 *              but with one added optimization.
 *
 * The optimization is that if the block is already at the end of the heap,
 * sbrk only the extra required size and update the header and footer.
 * No memcpy call is required and return the pointer that was passed in.
 */
void *mm_realloc(void *ptr, size_t size)
{
    unsigned blkSize = GET_SIZE(HDRP(ptr));
    if (realloc_size(size, 0) < blkSize) {
      return ptr;
    }

    // coalesce with sbrk
    if (NEXT_BLKP(ptr) == ADD_PTR(mem_heap_hi(), 1)) {
      unsigned allocSize = realloc_size(size, OVERHEAD) - blkSize;
      mem_sbrk(allocSize);
      alloc_ptr(ptr, realloc_size(size, OVERHEAD));

      // set allocation before the last block
      PUT_INT(HDRP(NEXT_BLKP(ptr)), 1);

      return ptr;
    }
/*
    // allocate coalesce with next free block

    // allocate coalesce with prev free block
*/
    void *newptr = mm_malloc((unsigned)size);
    if (newptr == NULL)
      return NULL;

    unsigned cpysize = MIN(blkSize - OVERHEAD, (unsigned)size);
    memcpy_8(newptr, ptr, cpysize);
    mm_free(ptr);

    return newptr;
}
Exemplo n.º 8
0
int  C_DELAY::save_config(unsigned char *data) 
{
	int pos=0;
	PUT_INT(mode);
	pos+=4;
	PUT_INT(activebuffer);
	pos+=4;
	if (creationid == 1)
	{
		for (int i=0;i<6;i++)
		{
			PUT_INT((int)usebeats[i]);
			pos+=4;
			PUT_INT(delay[i]);
			pos+=4;
		}
	}
	return pos;
}
Exemplo n.º 9
0
int  C_THISCLASS::save_config(unsigned char *data) // write configuration to data, return length. config data should not exceed 64k.
{
	int pos=0;
	PUT_INT(enabled); pos+=4;
	PUT_INT(density); pos+=4;
	PUT_INT(depth); pos+=4;
	PUT_INT(random_drop); pos+=4;
	PUT_INT(drop_position_x); pos+=4;
	PUT_INT(drop_position_y); pos+=4;
	PUT_INT(drop_radius); pos+=4;
	PUT_INT(method); pos+=4;
	return pos;
}
Exemplo n.º 10
0
/*
 * mm_init - initialize the malloc package.
 *
 * Allocates free_list next and prev pointers as a circular linked list.
 * Creates an "allocated" footer to prevent coalescing at the start of the
 * heap.
 */
int mm_init(void)
{
    // for free_list head and tail
    mem_sbrk(2 * DSIZE);
    // set head and tail to point to free_list
    PUT(PREV_PTR(free_list), free_list);
    PUT(NEXT_PTR(free_list), free_list);
    // ensure there is space for an extra double word before the heap begins
    void *heap_start = mem_sbrk(DSIZE);
    // set allocation before the first block
    PUT_INT(heap_start, 1);
    return 0;
}
Exemplo n.º 11
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0;
	PUT_INT(enabled); pos+=4;
  PUT_INT(faders[0]); pos+=4;
  PUT_INT(faders[1]); pos+=4;
  PUT_INT(faders[2]); pos+=4;
  PUT_INT(beatfaders[0]); pos+=4;
  PUT_INT(beatfaders[1]); pos+=4;
  PUT_INT(beatfaders[2]); pos+=4;
	return pos;
}
Exemplo n.º 12
0
int  C_THISCLASS::save_config(unsigned char *data) // write configuration to data, return length. config data should not exceed 64k.
{
  int pos=0;
  PUT_INT(enabled); pos+=4;
  PUT_INT(arbitrary); pos+=4;
  PUT_INT(skip); pos+=4;
  PUT_INT(invert); pos+=4;
  PUT_INT(arbVal); pos+=4;
  PUT_INT(skipVal); pos+=4;
  PUT_INT(skipfirst); pos+=4;
  return pos;
}
Exemplo n.º 13
0
void C_RBASE::save_string(unsigned char *data, int &pos, RString &text)
{
  if (text.get() && text.get()[0])
	{
    char *p=text.get();
    int x=32768;
    while (x-- && *p) p++;
    if (*p)
    {
      MessageBox(NULL,"Yo, this is some long ass shit","F**K!",MB_OK);
      //FUCKO
    }
    int l=(strlen(text.get())+1);
	  PUT_INT(l); pos+=4;
	  memcpy(data+pos, text.get(), strlen(text.get())+1);
	  pos+=strlen(text.get())+1;
	}
  else
  { 
    PUT_INT(0); 
    pos+=4;
  }
}
Exemplo n.º 14
0
void GetComponentID()
{
	char buf[BUFSIZE];
	SDMService service;
	SDMData data;
	
	service.source = DataManager;
	service.source.setSensorID(1);  //DataManager sensor_id is always 1
	service.destination.setPort(my_port);
	service.command_id = 264;  //Could be queried for by using a SDMReqReg with item_name = ReturnSensorID
	service.length = 4;
	PUT_INT(service.data,PID);
	service.Send();

	mm.BlockGetMessage(buf);
	data.Unmarshal(buf);

	my_PID = GET_LONG(data.msg);
	my_sensorID = GET_LONG(&data.msg[4]);  //Could be gotten from the Messagemanipulator
	printf("My PID is %ld\n",my_PID);
	printf("My sensor_id is %ld\n",my_sensorID);
}
Exemplo n.º 15
0
/*
 * mm_malloc - Allocate as an explicit free list.
 *
 * This is done using a first fit policy on the minimum size of the block.
 * The first fitting block may be split up into a smaller free block and an
 * allocated free block to fit the block requested by malloc. The free block
 * will precede the allocated block to prevent the need to move pointers.
 *
 * If the block does not fit, a new allocated block is created, which may
 * round the block size up to the nearest power of 2. An "allocated" block is
 * created at the end to prevent coalescing past the heap end.
 */
void *mm_malloc(size_t size)
{
    // use malloc_size or fit_size
    unsigned newsize = fit_size(size);
    // finger = free_list->next
    size_t *finger = (size_t *)GET(NEXT_PTR(free_list));
    size_t *p = (size_t *)free_list;
    unsigned fitSize = ~0;
    // iterate linked list
    while (finger != free_list) {
      unsigned blkSize = GET_SIZE(HDRP(finger));
      // look for best fit, exit early if perfect fit
      if (blkSize == newsize) {
        p = finger;
        break;
      }
      // remember best fit
      if (blkSize > newsize && blkSize < fitSize) {
        p = finger;
        fitSize = blkSize;
      }
      // finger = finger->next
      finger = (size_t *)GET(NEXT_PTR(finger));
    }
    // if block doesn't fit in any free block, allocate more heap space
    if (p == free_list) {
      // round up with malloc_size
      newsize = malloc_size(size);
      // if block before end of heap is a free block, coalesce
      void *prevPtr = PREV_BLKP(ADD_PTR(mem_heap_hi(), 1));
      if (prevPtr < mem_heap_hi() && !GET_ALLOC(HDRP(prevPtr))) {
        // calculate new size to sbrk
        unsigned allocSize = newsize - GET_SIZE(HDRP(prevPtr));
        p = mem_sbrk(allocSize);
        if ((int)(p) == -1)
          return NULL;

        // prevPtr->prev->next = prevPtr->next;
        PUT(NEXT_PTR(GET(PREV_PTR(prevPtr))), GET(NEXT_PTR(prevPtr)));
        // prevPtr->next->prev = prevPtr->prev;
        PUT(PREV_PTR(GET(NEXT_PTR(prevPtr))), GET(PREV_PTR(prevPtr)));
        // allocate prevPtr to new size
        alloc_ptr(prevPtr, newsize);

        // set allocation before the last block
        PUT_INT(HDRP(NEXT_BLKP(prevPtr)), 1);

        return prevPtr;
      }
      p = mem_sbrk(newsize);
      if ((int)(p) == -1)
        return NULL;

      alloc_ptr(p, newsize);

      // set allocation before the last block
      PUT_INT(HDRP(NEXT_BLKP(p)), 1);
      
      return p;
    }
    unsigned freeSize = GET_SIZE(HDRP(p));
    if (freeSize - newsize >= FREE_OVERHEAD) {
      // split free block into free and allocated blocks

      unsigned header = freeSize - newsize;
      // header
      PUT_INT(HDRP(p), header);
      // footer
      PUT_INT(FTRP(p), header);
      p = ADD_PTR(p, freeSize - newsize);
    } else {
      // allocate the whole free block
      newsize = freeSize;
      // p->prev->next = p->next
      PUT(NEXT_PTR(GET(PREV_PTR(p))), GET(NEXT_PTR(p)));
      // p->next->prev = p->prev
      PUT(PREV_PTR(GET(NEXT_PTR(p))), GET(PREV_PTR(p)));
    }
    // sets header and footer with allocate bit set 
    alloc_ptr(p, newsize);

    return p;
}
Exemplo n.º 16
0
/* put header and footer for an allocated block */
void alloc_ptr(void *ptr, unsigned size)
{
    unsigned header = PACK(size, 1);
    PUT_INT(HDRP(ptr), header);
    PUT_INT(FTRP(ptr), header);
}
Exemplo n.º 17
0
int  C_THISCLASS::save_config(unsigned char *data) // write configuration to data, return length. config data should not exceed 64k.
{
  int pos=0;
  
	PUT_INT(enabled); pos+=4;
  PUT_INT(nPoints); pos+=4;
  PUT_INT(rotation); pos+=4;
  PUT_INT(distance); pos+=4;
  PUT_INT(alpha); pos+=4;
  PUT_INT(rotationinc); pos+=4;
  PUT_INT(blend); pos+=4;
  PUT_INT(blendavg); pos+=4;
  PUT_INT(distance2); pos+=4;
  PUT_INT(alpha2); pos+=4;
  PUT_INT(rotationinc2); pos+=4;
  PUT_INT(rgb); pos+=4;
  PUT_INT(onbeat); pos+=4;
  PUT_FLOAT(speed, data, pos); pos+=4;

	return pos;
}
Exemplo n.º 18
0
int  C_THISCLASS::save_config(unsigned char *data)
{
	int pos=0;
	PUT_INT(newmode); pos+=4;
	return pos;
}