Exemplo n.º 1
0
mpi_free_gpg_limb_space( mpi_ptr_t a )
#endif
{
    if( !a )
	return;
    if( DBG_MEMORY )
	log_debug("mpi_free_gpg_limb_space of size %lu\n", (ulong)m_size(a)*8 );

#if 0
    if( !m_is_secure(a) ) {
	size_t nlimbs = m_size(a) / 4 ;
	void *p = a;

	if( nlimbs == 5 ) {  /* DSA 160 bits */
	    *a = unused_limbs_5;
	    unused_limbs_5 = a;
	    return;
	}
	else if( nlimbs == 32 ) {  /* DSA 1024 bits */
	    *a = unused_limbs_32;
	    unused_limbs_32 = a;
	    return;
	}
	else if( nlimbs == 64 ) {  /* DSA 2*1024 bits */
	    *a = unused_limbs_64;
	    unused_limbs_64 = a;
	    return;
	}
    }
#endif

    xfree(a);
}
Exemplo n.º 2
0
const Transform& View::getTransform() const
{
	// Recompute the matrix if needed
	if (!m_transformUpdated)
	{
		// Rotation components
		m_center = Vec2f(m_rect.left + (m_rect.width / 2), m_rect.top + (m_rect.height / 2));
		Vec2f m_size(m_rect.width,m_rect.height);

		float angle  = m_rotation * 3.141592654f / 180.f;
		float cosine = static_cast<float>(std::cos(angle));
		float sine   = static_cast<float>(std::sin(angle));
		float tx     = -m_center.x * cosine - m_center.y * sine + m_center.x;
		float ty     =  m_center.x * sine - m_center.y * cosine + m_center.y;

		// Projection components
		float a =  2.f / m_size.x;
		float b = -2.f / m_size.y;
		float c = -a * m_center.x;
		float d = -b * m_center.y;

		// Rebuild the projection matrix
		m_transform = Transform( a * cosine, a * sine,   a * tx + c,
			-b * sine,   b * cosine, b * ty + d,
			0.f,        0.f,        1.f);
		m_transformUpdated = true;
	}

	return m_transform;
}
Exemplo n.º 3
0
TerrainObject::TerrainObject(const QString &imageFile, const QPoint &pos): Object(imageFile, pos){
	QSize m_size(SIZE, SIZE);
	QPixmap image;

	ImageLoader loader(imageFile);

	image = loader.retrieve("terrain", m_size);

	setPixmap(image);

	setData(0, "Object");
	setData(1, "Terrain");
	setZValue(1);
}
Exemplo n.º 4
0
EnergyItem::EnergyItem(const QString &imageFile, const QPoint &pos, const int &value):
		Object(imageFile, pos),
		m_value(value){
	QSize m_size(SIZE, SIZE);
	QPixmap image;

	ImageLoader loader(imageFile);

	image = loader.retrieve("energy", m_size);

	setPixmap(image);

	setData(0, "Item");
	setData(1, "Energy");
	setZValue(2);
}
Exemplo n.º 5
0
Arquivo: malloc.c Projeto: Abioy/FUZIX
/* This function will search for a chunk in memory of at least 'mem_size'
 * when found, if the chunk is too big it'll be split, and pointer to the
 * chunk returned. If none is found NULL is returned.
 */
Static mem *__search_chunk(unsigned mem_size)
{
	register mem *p1, *p2;
	if (chunk_list == 0)	/* Simple case first */
		return 0;

	/* Search for a block >= the size we want */
	p1 = m_next(chunk_list);
	p2 = chunk_list;

	do {
		noise("CHECKED", p1);
		if (m_size(p1) >= mem_size)
			break;
		p2 = p1;
		p1 = m_next(p1);
	} while (p2 != chunk_list);

	/* None found, exit */
	if (m_size(p1) < mem_size)
		return 0;

	/* If it's exactly right remove it */
	if (m_size(p1) < mem_size + 2) {
		noise("FOUND RIGHT", p1);
		chunk_list = m_next(p2) = m_next(p1);
		if (chunk_list == p1)
			chunk_list = 0;
		return p1;
	}
	noise("SPLIT", p1);

	/* Otherwise split it */
	m_next(p2) = m_add(p1, mem_size);
	chunk_list = p2;
	p2 = m_next(p2);
	m_size(p2) = m_size(p1) - mem_size;
	m_next(p2) = m_next(p1);
	m_size(p1) = mem_size;
	if (chunk_list == p1)
		chunk_list = p2;

#ifdef VERBOSE
	p1[1].size = 0xAAAA;

#endif				/*  */
	noise("INSERT CHUNK", p2);
	noise("FOUND CHUNK", p1);
	noise("LIST IS", chunk_list);
	return p1;
}
Exemplo n.º 6
0
Arquivo: malloc.c Projeto: Abioy/FUZIX
void *malloc(size_t size)
{
	register unsigned sz;
	register mem *ptr = 0;
	if (size == 0)
		return 0;	/* ANSI STD */
	sz = size + sizeof(struct mem_cell);

#ifdef MINALLOC
	if (sz < MINALLOC)
		sz = MINALLOC;

#endif				/*  */
#ifdef VERBOSE
	{
		static mem arr[2];
		m_size(arr) = sz;
		noise("WANTED", arr);
	}
#endif				/*  */
	__alloca_alloc = malloc;	/* We'll be messing with the heap now TVM */

#ifdef LAZY_FREE
	ptr = __search_chunk(sz);
	if (ptr == 0) {

#endif				/*  */
		/* First deal with the freed list */
		if (__freed_list) {
			while (__freed_list) {
				ptr = __freed_list;
				__freed_list = m_next(__freed_list);
				if (m_size(ptr) == sz) {

					/* Oh! Well that's lucky ain't it :-) */
					noise("LUCKY MALLOC", ptr);
					return ptr + 1;
				}
				__insert_chunk(ptr);
			}
			ptr = m_next(chunk_list);
			if (ptr + m_size(ptr) >= (void *) sbrk(0)) {

				/* Time to free for real */
				m_next(chunk_list) = m_next(ptr);
				if (ptr == m_next(ptr))
					chunk_list = 0;
				free(ptr + 1);
			}
#ifdef LAZY_FREE
			ptr = __search_chunk(sz);

#endif				/*  */
		}
#ifndef LAZY_FREE
		ptr = __search_chunk(sz);

#endif				/*  */
		if (ptr == 0) {

#ifdef MCHUNK
			unsigned int alloc =
			    (MCHUNK * ((sz + MCHUNK - 1) / MCHUNK) - 1);
			if ((ptr = __mini_malloc(alloc)) != NULL)
				__insert_chunk(ptr - 1);

			else {	/* Oooo, near end of RAM */
				unsigned int needed = alloc;
				alloc /= 2;
				while (alloc > 256 && needed) {
					ptr = __mini_malloc(alloc);
					if (ptr) {
						if (alloc > needed)
							needed = 0;

						else
							needed -= alloc;
						__insert_chunk(ptr - 1);
					}

					else
						alloc /= 2;
				}
			}
			ptr = __search_chunk(sz);
			if (ptr == 0)
#endif				/*  */
			{

#ifndef MCHUNK
				ptr = __mini_malloc(size);

#endif				/*  */
#ifdef VERBOSE
				if (ptr == 0)
					noise("MALLOC FAIL", 0);

				else
					noise("MALLOC NOW", ptr - 1);

#endif				/*  */
				return ptr;
			}
		}
#ifdef LAZY_FREE
	}
#endif				/*  */
#ifdef VERBOSE
	ptr[1].size = 0x5555;

#endif				/*  */
	noise("MALLOC RET\n", ptr);
	return ptr + 1;
}
Exemplo n.º 7
0
Arquivo: malloc.c Projeto: Abioy/FUZIX
/* This function takes a pointer to a block of memory and inserts it into
 * the chain of memory chunks
 */
Static void __insert_chunk(mem * mem_chunk)
{
	register mem *p1, *p2;
	if (chunk_list == 0) {	/* Simple case first */
		m_next(mem_chunk) = chunk_list = mem_chunk;
		noise("FIRST CHUNK", mem_chunk);
		return;
	}
	p1 = mem_chunk;
	p2 = chunk_list;

	do {
		if (p1 > p2) {

			/* We're at the top of the chain, p1 is higher */
			if (m_next(p2) <= p2) {
				if (m_add(p2, m_size(p2)) == p1) {

					/* Good, stick 'em together */
					noise("INSERT CHUNK", mem_chunk);
					m_size(p2) += m_size(p1);
					noise("JOIN 1", p2);
				}

				else {
					m_next(p1) = m_next(p2);
					m_next(p2) = p1;
					noise("INSERT CHUNK", mem_chunk);
					noise("FROM", p2);
				}
				return;
			}
			if (m_next(p2) > p1) {

				/* In chain, p1 between p2 and next */
				m_next(p1) = m_next(p2);
				m_next(p2) = p1;
				noise("INSERT CHUNK", mem_chunk);
				noise("FROM", p2);

				/* Try to join above */
				if (m_add(p1, m_size(p1)) == m_next(p1)) {
					m_size(p1) += m_size(m_next(p1));
					m_next(p1) = m_next(m_next(p1));
					noise("JOIN 2", p1);
				}

				/* Try to join below */
				if (m_add(p2, m_size(p2)) == p1) {
					m_size(p2) += m_size(p1);
					m_next(p2) = m_next(p1);
					noise("JOIN 3", p2);
				}
				chunk_list = p2;	/* Make sure it's valid */
				return;
			}
		}

		else if (p1 < p2) {
			if (m_next(p2) <= p2 && p1 < m_next(p2)) {

				/* At top of chain, next is bottom of chain,
				 * p1 is below next
				 */
				m_next(p1) = m_next(p2);
				m_next(p2) = p1;
				noise("INSERT CHUNK", mem_chunk);
				noise("FROM", p2);
				chunk_list = p2;
				if (m_add(p1, m_size(p1)) == m_next(p1)) {
					if (p2 == m_next(p1))
						chunk_list = p1;
					m_size(p1) += m_size(m_next(p1));
					m_next(p1) = m_next(m_next(p1));
					noise("JOIN 4", p1);
				}
				return;
			}
		}
		chunk_list = p2;	/* Save for search */
		p2 = m_next(p2);
	} while (p2 != chunk_list);

	/* If we get here we have a problem, ignore it, maybe it'll go away */
	noise("DROPPED CHUNK", mem_chunk);
}
Exemplo n.º 8
0
uint JVector<T>::size() const
{
	return m_size();
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
   {
   register int i;
   int xpos = XPOS;
   int ypos = YPOS;
   int font = -1;
   int shape = 1;

   char *getenv();
   char *home = getenv("HOME");
   int clean(), update();

   /* make sure we have a valid environment to run in */

   ckmgrterm( *argv );

   if (home==NULL || *home=='\0') {
      fprintf(stderr,"%s: Can't find your home directory\n",argv[0]);
      exit(1);
      }

   if ((bounds = fopen(BOUNDS,"r")) == NULL) {
      fprintf(stderr,"%s: Can't find a bounds file\n",argv[0]);
      exit(2);
      }

   sprintf(line,"%s/%s",home,RC);
   
   if ((rc = fopen(line,"r")) == NULL) {
      fprintf(stderr,"%s: Can't find %s\n",argv[0],line);
      exit(3);
      }

   /* process arguments */

   for(i=1;i<argc;i++) {
      if (Isflag(argv[i],"-s"))
         shape = 0;
      else if (Isflag(argv[i],"-x"))
         xpos = atoi(argv[i]+2);
      else if (Isflag(argv[i],"-y"))
         ypos = atoi(argv[i]+2);
      else if (Isflag(argv[i],"-f"))
         font = atoi(argv[i]+2);
      else if (Isflag(argv[i],"-p"))
         poll  = Max(atoi(argv[i]+2),10);
      else
         usage(argv[0],argv[i]);
      }

   /* setup mgr stuff */

   m_setup(M_FLUSH);
   m_push(P_MENU|P_EVENT|P_FLAGS);
   m_setmode(M_NOWRAP);
   m_ttyset();

   signal(SIGTERM,clean);
   signal(SIGINT,clean);
   signal(SIGALRM,update);

   menu_load(1,MENU_COUNT,menu);
   m_selectmenu(1);

   old_msg_cnt = MSGS();
   get_msg(line,old_msg_cnt);
   if (shape) {
      m_setmode(M_ACTIVATE);
      m_size(strlen(line)+2,1);
      }
   m_printstr(line);
   m_setevent(REDRAW,"R\n");
   m_setevent(ACTIVATED,"A\n");
   m_clearmode(M_ACTIVATE);
   alarm(poll);

   while(1) {
      char buff[80];
      m_gets(buff);
      alarm(0);

      /* read msgs */

      old_msg_cnt = msg_cnt;
      msg_cnt = MSGS();
      if (msg_cnt > 0 && *buff == 'A') {
         m_push(P_POSITION|P_EVENT|P_FLAGS|P_FONT);
         if (font != -1)
            m_font(font);
         m_sizeall(xpos,ypos,80,24);
         m_printstr("\freading msgs...\r");
         m_ttyreset();
         system(MSGSCMD);
         m_gets(buff);
         m_ttyset();
         m_pop();
         }

      /* wait for window to deactivate */

      else if (*buff == 'A') {
         m_setevent(DEACTIVATED,RESUME);
         do {
            m_printstr("\f Your msgs system here        ");
            m_gets(buff);
            } while(!SCMP(buff,RESUME));
         m_clearevent(DEACTIVATED);
         }
      old_msg_cnt = msg_cnt;
      msg_cnt = MSGS();
      get_msg(line,msg_cnt);
      m_printstr(line);
      m_clearmode(M_ACTIVATE);
      alarm(poll);
      }
      return 0;
   }