void testCheckMem()	{

    GameProperties testGame;
    testGame = getGame(NULL);
    setMemory(0);
    addMemory(10);
    sput_fail_unless(checkMem(10,testGame) == 1,"boundary Testing enough memory");
    useMemory(testGame,10);
    sput_fail_unless(checkMem(50,testGame) == 0,"Testing not enough memory");
    addMemory(100);
    sput_fail_unless(checkMem(100,testGame) == 1,"Testing enough memory");
    setMemory(0);
    test_KillAnEnemy();
    sput_fail_unless(getAvailableMemory() > 0, "Valid: More memory available after killing an enemy");
    freeAllEnemies();
}
Beispiel #2
0
void *main_thread(void *)
{
#ifdef SIMU_EXCEPTIONS
  signal(SIGFPE, sig);
  signal(SIGSEGV, sig);

  try {
#endif
    eeReadAll(); //load general setup and selected model

    if (main_thread_running == 1) {
      checkMem();  //enough eeprom free?
      checkTHR();
      checkSwitches(); //must be last
    }

    chainMenu(menuProc0); //call evt_entry

    while (main_thread_running) {
      perMain();
      sleep(1/*ms*/);
    }
#ifdef SIMU_EXCEPTIONS
  }
  catch (...) {
    main_thread_running = 0;
  }
#endif

  return NULL;
}
Beispiel #3
0
expr* symExpr(symbol* sym) {
 if (!sym) return NULL;
 expr* ex = malloc(sizeof(expr));
 checkMem(ex);
 ex->oper = ex->paren = 0;
 ex->next = NULL;
 ex->sym = sym;
 return ex;
}
Beispiel #4
0
expr* colonExpr(symbol* sym, expr* ex) {
 expr* assignment = malloc(sizeof(expr) + sizeof(expr*));
 checkMem(assignment);
 assignment->oper = ':';
 assignment->next = NULL;
 assignment->sym = sym;
 assignment->paren = 0;
 sym->truth = 0;
 assignment->args[0] = ex;
 return assignment;
}
Beispiel #5
0
expr* opExpr(int op, expr* left, expr* right) {
 expr* operation = malloc(sizeof(expr) + 2 * sizeof(expr*));
 checkMem(operation);
 operation->oper = op;
 operation->next = NULL;
 operation->sym = NULL;
 operation->paren = 0;
 operation->args[0] = left;
 operation->args[1] = right;
 return operation;
}
Beispiel #6
0
expr* notExpr(expr* ex) {
 if (!ex) return NULL;
 expr* negation = malloc(sizeof(expr) + sizeof(expr*));
 checkMem(negation);
 negation->oper = NOT;
 negation->next = NULL;
 negation->sym = NULL;
 negation->args[0] = ex;
 negation->paren = 0;
 return negation;
}
Beispiel #7
0
void initMalloc(){
	long length = checkMem();
	length *= 1048576;
	minsegment = (int)((sizeof(mem_segment)*(length-(0.1*length))/(0.1*length)));
	length -= (int)(0.1*length)+1;
	startsegment = BASE_SEGMENT + (int)(0.1*length)+1;
	mem_header node = (mem_header)BASE_SEGMENT;
	node->next = NULL;
	node->length = length;
	node->used = FALSE;
	node->loc = startsegment;
	lastsegment = BASE_SEGMENT + length;
}
Beispiel #8
0
void TInfoSinkBase::append(const TString& t)
{ 
    if (outputStream & EString) {
        checkMem(t.size());  
        sink.append(t.c_str()); 
    }

#ifdef _WIN32
    if (outputStream & EDebugger)
        OutputDebugString(t.c_str());
#endif

    if (outputStream & EStdOut)
        fprintf(stdout, "%s", t.c_str());
}
Beispiel #9
0
void TInfoSinkBase::append(const char *s)           
{
    if (outputStream & EString) {
        checkMem(strlen(s)); 
        sink.append(s); 
    }

#ifdef _WIN32
    if (outputStream & EDebugger)
        OutputDebugString(s);
#endif

    if (outputStream & EStdOut)
        fprintf(stdout, "%s", s);
}
Beispiel #10
0
symbol* getSym(char c) {
 symbol *s = symTbl, *prev = NULL;
 for (; s != NULL; prev = s, s = s->next)
  if (s->c == c) {s->refQty++; return s; }
 symbol* sym = malloc(sizeof(symbol));
 checkMem(sym);
 sym->c = c;
 sym->truth = 1;
 sym->refQty = 1;
 sym->next = NULL;
 if (prev == NULL) symTbl = sym;
 else prev->next = sym;
 symQty++;
 return sym;
}
Beispiel #11
0
int readString(char **outString, int maxBuffer)
{
    *outString = calloc(1, maxBuffer);
    checkMem(*outString);

    char *result = fgets(*outString, maxBuffer, stdin);
    check(result != NULL, "Input error.");

    return 0;

error:
    if (*outString) free(*outString);
    *outString = NULL;
    return -1;
}
Beispiel #12
0
void TInfoSinkBase::append(int count, char c)       
{ 
    if (outputStream & EString) {
        checkMem(count);         
        sink.append(count, c); 
    }

#ifdef _WIN32
    if (outputStream & EDebugger) {
        char str[2];
        str[0] = c;
        str[1] = '\0';
        OutputDebugString(str);
    }
#endif

    if (outputStream & EStdOut)
        fprintf(stdout, "%c", c);
}
Beispiel #13
0
int readStr(FILE* file, STRING** table)
{
    int chr = 0;
    long addr = 0;
    unsigned long long hash = 0;
    int i = 0;

    addr = ftell(file);

    while(EOF != (chr = fgetc(file)))
    {
        if(chr == '\n' || chr == 0)
        {
            break;
        }

        hash += hash * 255 + chr;
    }

    i = findHash(hash, table);

    if(table[i])
    {
        table[i]->freq++;
    }else
    {
        table[i] = (STRING*)malloc(sizeof(STRING));
        checkMem(table[i]);
        table[i]->addr = addr;
        table[i]->freq = 1;
        table[i]->hash_ = hash;
    }

    table[i + 1] = NULL;

    return ((chr == EOF) ? 0 : 1);
}
Beispiel #14
0
void TInfoSinkBase::append(int count, char c)       
{
   checkMem(count);         
   sink.append(count, c); 
}
int checkQueue(ActionQueueStructure queue, GameProperties Game, int needed)	{
    if((checkMem(needed, Game)) && (checkClock(lastCmdAction,ACTIONCOOLDOWN)))	{
        return 1;
    }
    return 0;
}
Beispiel #16
0
void TInfoSinkBase::append(const char *s)           
{
   checkMem(strlen(s)); 
   sink.append(s); 
}
Beispiel #17
0
void TInfoSinkBase::append(const TString& t)
{
   checkMem(t.size());  
   sink.append(t.c_str()); 
}
Beispiel #18
0
void TInfoSinkBase::append(const TPersistString& t) 
{
   checkMem(t.size());  
   sink.append(t); 
}