void SCRIPT_AddEntry ( int32 scripthandle, const char * sectionname, const char * entryname, const char * entryvalue ) { ScriptSectionType *s; ScriptEntryType *e,*e2; if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return; if (!sectionname || !entryname || !entryvalue) return; if (!SC(scripthandle)) return; // s = SCRIPT_SectionExists(scripthandle, sectionname); // if (!s) { s = SCRIPT_AddSection(scripthandle, sectionname); if (!s) return; // } e = SCRIPT_EntryExists(s, entryname); if (!e) { AllocEntry(e); e->name = strdup(entryname); if (!s->entries) { s->entries = e; } else { e2 = s->entries; while (e2->nextentry != e2) e2=e2->nextentry; e2->nextentry = e; e->preventry = e2; } } if (e->value) free(e->value); e->value = strdup(entryvalue); }
HLEHelperThread::HLEHelperThread(const char *threadName, const char *module, const char *func, u32 prio, int stacksize) { const u32 bytes = sizeof(u32) * 2; AllocEntry(bytes); Memory::Write_U32(MIPS_MAKE_JR_RA(), entry_ + 0); Memory::Write_U32(MIPS_MAKE_SYSCALL(module, func), entry_ + 4); Create(threadName, prio, stacksize); }
infilelist * AllocFileEntry( char *name, path_entry * path ) /*****************************************************************/ { infilelist * entry; entry = AllocEntry( name, path ); entry->next = CachedFiles; CachedFiles = entry; return entry; }
HLEHelperThread::HLEHelperThread(const char *threadName, u32 instructions[], u32 instrCount, u32 prio, int stacksize) { u32 instrBytes = instrCount * sizeof(u32); u32 totalBytes = instrBytes + sizeof(u32) * 2; AllocEntry(totalBytes); Memory::Memcpy(entry_, instructions, instrBytes); // Just to simplify things, we add the return here. Memory::Write_U32(MIPS_MAKE_JR_RA(), entry_ + instrBytes + 0); Memory::Write_U32(MIPS_MAKE_NOP(), entry_ + instrBytes + 4); Create(threadName, prio, stacksize); }
void NativeProfilerImpl::sampleNative(void* addr, uint32_t size) { AutoUseUncensoredAllocator ua; AutoMPLock lock(mLock); size_t nSamples = AddBytesSampled(size); if (nSamples > 0) { nsTArray<nsCString> trace = GetStacktrace(); AllocEvent ai(mTraceTable.Insert(trace), nSamples * mSampleSize, TimeStamp::Now()); mNativeEntries.Put(addr, AllocEntry(mAllocEvents.Length())); mAllocEvents.AppendElement(ai); } }
infilelist * AllocUniqueFileEntry( char *name, path_entry *path ) /**********************************************************************/ { infilelist * entry; for( entry = CachedLibFiles; entry != NULL; entry = entry->next ) { if( FNAMECMPSTR( entry->name, name ) == 0 ) { return entry; // we found 1 with the same name. } } entry = AllocEntry( name, path ); // didn't find one, so allocate a new 1 if( CachedLibFiles == NULL ) { // add libraries to the end of the CachedLibFiles = entry; // regular cached files list. LinkList( &CachedFiles, entry ); } else { LinkList( &CachedLibFiles, entry ); } return entry; }
Transition* AutomAllocator::allocateTransitions(int cap) { IFDEBUG(allocTrCalls++); Transition* result; if(!pools[cap].isEmpty()) { IFDEBUG(allocTrHits++); result = pools[cap].pop(); } else { IFDEBUG(allocTrMiss++); AllocEntry& e = allocPool.peek(); if(e.next + cap < BLOCK_SIZE) { result = (e.ptr + e.next); e.next += cap; } else { Transition* newPool = (Transition*) malloc(BLOCK_SIZE * sizeof(Transition)); if(e.next < BLOCK_SIZE) pools[BLOCK_SIZE - (e.next + 1)].push(e.ptr + e.next); allocPool.push(AllocEntry(newPool, cap)); result = newPool; } } return result; }
struct Task *CreateTask(STRPTR name, LONG pri, APTR initpc, ULONG stacksize) { struct Library *SysBase = *(struct Library **)4L; struct newMemList nml; struct MemList *ml; struct Task *newtask; APTR task2; stacksize=(stacksize+3)&~3; { long *p1,*p2; int i; for (p1=(long *)&nml,p2=(long*)&MemTemplate,i=7; i; *p1++=*p2++,i--) ; *p1=stacksize; } if (!(((unsigned int)ml=AllocEntry((struct MemList *)&nml)) & (1<<31))) { newtask=ml->ml_ME[0].me_Addr; newtask->tc_Node.ln_Type = NT_TASK; newtask->tc_Node.ln_Pri = pri; newtask->tc_Node.ln_Name = name; newtask->tc_SPReg = (APTR)((ULONG)ml->ml_ME[1].me_Addr+stacksize); newtask->tc_SPLower = ml->ml_ME[1].me_Addr; newtask->tc_SPUpper = newtask->tc_SPReg; NEWLIST(&newtask->tc_MemEntry); AddHead(&newtask->tc_MemEntry,&ml->ml_Node); task2=AddTask(newtask,initpc,0); if (SysBase->lib_Version>36 && !task2) { FreeEntry(ml); newtask = NULL; } } else newtask = NULL; return newtask; }
AutomAllocator::AutomAllocator() { Transition* newPool = (Transition*) malloc(BLOCK_SIZE * sizeof(Transition)); allocPool.push(AllocEntry(newPool, 0)); }