本文整理汇总了C++中AllocVec函数的典型用法代码示例。如果您正苦于以下问题:C++ AllocVec函数的具体用法?C++ AllocVec怎么用?C++ AllocVec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AllocVec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: L_OpenBuf
// Open a buffered file
APTR LIBFUNC L_OpenBuf(
REG(a0, char *name),
REG(d0, long mode),
REG(d1, long buffer_size))
{
BufFile *file;
// Allocate file handle
if (!(file=AllocVec(sizeof(BufFile),MEMF_CLEAR)))
return 0;
// Open file
if (!(file->file=Open(name,mode)))
{
FreeVec(file);
return 0;
}
// Store DOS pointer
file->dos=DOSBase;
// Allocate buffer
if (buffer_size>0)
{
if ((file->buffer=AllocVec(buffer_size,0)))
file->buffer_size=buffer_size;
}
return file;
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:31,代码来源:buffered_io.c
示例2: schedule
void schedule(int t, void (*callback)(void *p), void *p)
{
struct nscallback *nscb;
struct TimeVal tv;
ULONG time_us = 0;
if(schedule_list == NULL) return;
nscb = AllocVec(sizeof(struct nscallback), MEMF_PRIVATE | MEMF_CLEAR);
if(!nscb) return;
time_us = t*10000; /* t converted to µs */
nscb->tv.Seconds = time_us / 1000000;
nscb->tv.Microseconds = time_us % 1000000;
GetSysTime(&tv);
AddTime(&nscb->tv,&tv); // now contains time when event occurs
if(nscb->treq = AllocVec(sizeof(struct TimeRequest),MEMF_PRIVATE | MEMF_CLEAR))
{
*nscb->treq = *tioreq;
nscb->treq->Request.io_Command=TR_ADDREQUEST;
nscb->treq->Time.Seconds=nscb->tv.Seconds; // secs
nscb->treq->Time.Microseconds=nscb->tv.Microseconds; // micro
SendIO((struct IORequest *)nscb->treq);
}
nscb->callback = callback;
nscb->p = p;
pblHeapInsert(schedule_list, nscb);
}
开发者ID:galexcode,项目名称:NetSurf68k,代码行数:33,代码来源:schedule.c
示例3: URLHistoryFound
static bool URLHistoryFound(const char *url, const struct url_data *data)
{
struct Node *node;
/* skip this URL if it is already in the list */
if(URLHistory_FindPage(url)) return true;
node = AllocVec( sizeof( struct Node ), MEMF_SHARED|MEMF_CLEAR );
if ( node )
{
STRPTR urladd = (STRPTR) AllocVec( strlen ( url ) + 1, MEMF_SHARED|MEMF_CLEAR );
if ( urladd )
{
strcpy(urladd, url);
node->ln_Name = urladd;
AddTail( &PageList, node );
}
else
{
FreeVec(node);
}
}
return true;
}
开发者ID:MarkieMark,项目名称:netsurf-git-svn,代码行数:25,代码来源:urlhistory.c
示例4: HOOKPROTONHNO
HOOKPROTONHNO(TreeView_ConstructHookFunction, APTR, struct MUIP_NListtree_ConstructMessage *ncm) {
DebOut("ncm: %lx\n", ncm);
struct TreeLine *line=(struct TreeLine *) AllocVec(sizeof(struct TreeLine), 0);
TVINSERTSTRUCT *is=(TVINSERTSTRUCT *) ncm->UserData;
DebOut("is: %lx\n", is);
DebOut("ncm->name: %s\n", ncm->Name);
if(line && is) {
line->config=(struct ConfigStruct *) AllocVec(sizeof(struct ConfigStruct), 0);
if(is->itemex.pszText) {
DebOut("is->itemex.pszText: %s\n", is->itemex.pszText);
strncpy(line->name, is->itemex.pszText, MAX_DPATH-1);
}
if(is->itemex.lParam) {
memcpy((void *) line->config, (const void *) is->itemex.lParam, sizeof(struct ConfigStruct));
}
}
else {
DebOut("NOT ENOUGH MEMORY!\n");
}
DebOut("return: %lx\n", line);
return line;
}
开发者ID:Kalamatee,项目名称:WinUAE,代码行数:29,代码来源:mui_tree.cpp
示例5: FreeTemplate
/* Parse a line for a template. Result should be freed via
FreeTemplate() */
APTR ParseTemplate(CONST_STRPTR temp, STRPTR line, APTR results)
{
ULONG *mem = (ULONG*)AllocVec(12,0);
if(mem)
{
struct RDArgs *rdargs = (struct RDArgs*)AllocDosObject(DOS_RDARGS,NULL);
if((mem[0] = (ULONG)rdargs))
{
LONG len = mystrlen(line)+2;
STRPTR buf = (STRPTR)AllocVec(len,0);
if((mem[1] = (ULONG)buf))
{
struct RDArgs *rd;
if (line) strcpy(buf,line);
buf[len-2]=10;
buf[len-1]=0;
rdargs->RDA_Buffer = NULL;
rdargs->RDA_Source.CS_Buffer = (UBYTE *)buf;
rdargs->RDA_Source.CS_Length = strlen(buf);
rdargs->RDA_Source.CS_CurChr = 0;
rd = ReadArgs(temp,(LONG*)results, rdargs );
if((mem[2] = (ULONG)rd))
{
return mem;
}
}
}
}
FreeTemplate(mem);
return NULL;
}
开发者ID:sba1,项目名称:simplemail,代码行数:37,代码来源:amigasupport.c
示例6: FT_New_Memory
FT_New_Memory( void )
{
FT_Memory memory;
#ifdef __amigaos4__
memory = (FT_Memory)AllocVec( sizeof ( *memory ), MEMF_SHARED );
#else
memory = (FT_Memory)AllocVec( sizeof ( *memory ), MEMF_PUBLIC );
#endif
if ( memory )
{
#ifdef __amigaos4__
memory->user = CreatePool( MEMF_SHARED, 16384, 16384 );
#else
memory->user = CreatePool( MEMF_PUBLIC, 16384, 16384 );
#endif
if ( memory->user == NULL )
{
FreeVec( memory );
memory = NULL;
}
else
{
memory->alloc = ft_alloc;
memory->realloc = ft_realloc;
memory->free = ft_free;
#ifdef FT_DEBUG_MEMORY
ft_mem_debug_init( memory );
#endif
}
}
return memory;
}
开发者ID:03050903,项目名称:libgdx,代码行数:35,代码来源:ftsystem.c
示例7: HiddVC4CreateDisplaytarget
static struct sw_displaytarget *
HiddVC4CreateDisplaytarget(struct sw_winsys *winsys, unsigned tex_usage,
enum pipe_format format, unsigned width, unsigned height,
unsigned alignment, unsigned *stride)
{
struct HiddVC4Displaytarget * spdt =
AllocVec(sizeof(struct HiddVC4Displaytarget), MEMF_PUBLIC | MEMF_CLEAR);
*stride = align(util_format_get_stride(format, width), alignment);
spdt->data = AllocVec(*stride * height, MEMF_PUBLIC | MEMF_CLEAR);
return (struct sw_displaytarget *)spdt;
}
开发者ID:Kalamatee,项目名称:mesa,代码行数:13,代码来源:vc4galliumclass.c
示例8: AllocVec
struct List *GetModes(struct AHIUnitPrefs *prefs) {
struct List *list;
list = AllocVec(sizeof(struct List), MEMF_CLEAR);
if(list) {
ULONG id = AHI_NextAudioID(AHI_INVALID_ID);
NewList(list);
while(id != AHI_INVALID_ID) {
struct ModeNode *t;
struct Node *node;
t = AllocVec( sizeof(struct ModeNode), MEMF_CLEAR);
if( t != NULL ) {
LONG realtime;
t->node.ln_Name = t->name;
t->ID = id;
realtime = FALSE;
AHI_GetAudioAttrs(id, NULL,
AHIDB_BufferLen, 80,
AHIDB_Name, (ULONG) t->node.ln_Name,
AHIDB_Realtime, (ULONG) &realtime,
TAG_DONE);
if((prefs->ahiup_Unit == AHI_NO_UNIT) || realtime ) {
// Insert node alphabetically
for(node = list->lh_Head;
node->ln_Succ;
node = node->ln_Succ) {
if(Stricmp(t->node.ln_Name,node->ln_Name) < 0)
break;
}
Insert(list, (struct Node *) t, node->ln_Pred);
}
else {
FreeVec(t);
}
}
id = AHI_NextAudioID(id);
}
}
return list;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:49,代码来源:support.c
示例9: lib_debug_libc_calloc
void *lib_AllocVec(unsigned long size, unsigned long attributes)
{
#ifdef LIB_DEBUG
void *ptr;
if (attributes & MEMF_CLEAR) {
ptr = lib_debug_libc_calloc(1, size);
} else {
ptr = lib_debug_libc_malloc(size);
}
#else
void *ptr = AllocVec(size, attributes);
#endif
#ifndef __OS2__
if (ptr == NULL && size > 0) {
fprintf(stderr, "error: lib_AllocVec failed\n");
exit(-1);
}
#endif
#ifdef LIB_DEBUG
lib_debug_alloc(ptr, size, 1);
#endif
return ptr;
}
开发者ID:Rakashazi,项目名称:emu-ex-plus-alpha,代码行数:26,代码来源:lib.c
示例10: get_fs_usage
int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
{
struct InfoData *info = (struct InfoData *)AllocVec(sizeof *info, MEMF_ANY);
int result = -1;
if (info) {
BPTR lock = Lock (path, SHARED_LOCK);
if (lock) {
if (Info (lock, info)) {
fsp->fsu_blocks = adjust_blocks (info->id_NumBlocks,
info->id_BytesPerBlock,
512);
fsp->fsu_bfree = fsp->fsu_bavail =
adjust_blocks (info->id_NumBlocks - info->id_NumBlocksUsed,
info->id_BytesPerBlock,
512);
fsp->fsu_files = fsp->fsu_ffree = -1;
result = 0;
}
UnLock (lock);
}
FreeVec (info);
}
return result;
}
开发者ID:Vairn,项目名称:PUAE,代码行数:26,代码来源:fsusage.c
示例11: AllocVec
struct SysSocket *Sys_Net_CreateSocket(struct SysNetData *netdata, enum netaddrtype addrtype)
{
struct SysSocket *s;
int r;
int one;
one = 1;
if (addrtype != NA_IPV4)
return 0;
s = AllocVec(sizeof(*s), MEMF_ANY);
if (s)
{
s->s = socket(AF_INET, SOCK_DGRAM, 0);
if (s->s != -1)
{
r = IoctlSocket(s->s, FIONBIO, (void *)&one);
if (r == 0)
{
return s;
}
CloseSocket(s->s);
}
FreeVec(s);
}
return 0;
}
开发者ID:classicQ,项目名称:classicQ.github.io,代码行数:31,代码来源:net_amitcp.c
示例12: lib_gadtools_f_CreateContext
/****************************
Function: CreateContext
Vector: 19
Offset: -114
Arguments: A0.L pointer to pointer to struct Gadget
Returns: D0.L pointer to stuct Gadget
****************************/
int lib_gadtools_f_CreateContext(emumsg_syscall_t *msg)
{
cpu_t *cpu;
struct Gadget **ptr;
DEBUG(4) dprintf("gadtools.library: lib_gadtools_f_CreateContext() called\n");
cpu = msg->proc->cpu;
DEBUG(5) dprintf(" Gadget ptr ptr (A0): 0x%x\n",cpu->a[0]);
/* Allocate temporary space for the pointer */
ptr = (struct Gadget **)AllocVec(sizeof(struct Gadget *),MEMF_PUBLIC|MEMF_CLEAR);
if(ptr == NULL) {
DEBUG(1) dprintf("Error: gadtools.library: lib_gadtools_f_CreateContext: Could not allocate temporary memory\n");
return HOOK_END_PROC;
}
/* Prepare syscall */
msg->arg[0]._aptr = (APTR)ptr;
/* Remember memory */
msg->internalPtr = ptr;
/* Do syscall */
return HOOK_SYSCALL;
}
开发者ID:moggen,项目名称:emumiga,代码行数:34,代码来源:f_createcontext.cpp
示例13: funced_decompile
// Decompile function string into list of functions
void funced_decompile(FuncEdData *data)
{
FunctionEntry *entry;
Cfg_Instruction *ins;
// Clear list
Att_RemList(data->function_list,REMLIST_SAVELIST|REMLIST_FREEDATA);
// Copy to function entry list
for (ins=(Cfg_Instruction *)data->function->instructions.mlh_Head;
ins->node.mln_Succ;
ins=(Cfg_Instruction *)ins->node.mln_Succ)
{
// Label?
if (ins->type==INST_LABEL)
{
// Store label
stccpy(data->label,ins->string,79);
continue;
}
// Allocate function entry
if ((entry=AllocVec(sizeof(FunctionEntry),MEMF_CLEAR)))
{
// Store function data
entry->type=ins->type;
if (ins->string) strcpy(entry->buffer,ins->string);
// Add entry to list
if (!(entry->node=Att_NewNode(data->function_list,0,(ULONG)entry,0)))
FreeVec(entry);
}
}
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:35,代码来源:function_editor.c
示例14: DEBUG
user_mapping *user_mapping::create(uint32_t length)
{
DEBUG(5) dprintf("user_mapping::create() called. length=%d\n", length);
uint8_t *mem = (uint8_t *)AllocVec(length, MEMF_PUBLIC|MEMF_CLEAR);
if(!mem)
return NULL;
user_mapping *mapping = new user_mapping(length, mem);
if(!mapping) {
FreeVec(mem);
return NULL;
}
emulator *emu = emulator::getEmulator();
uint32_t new_address = emu->v_space.add_mapping(mapping);
// TODO: Add to r_space too?
if(new_address == 0xFFFFFFFF) {
delete mapping;
return NULL;
}
return mapping;
}
开发者ID:moggen,项目名称:emumiga,代码行数:27,代码来源:user_mapping.cpp
示例15:
// Get a toolbar
ToolBarInfo *OpenToolBar(Cfg_ButtonBank *buttons,char *pathname)
{
ToolBarInfo *toolbar;
// Allocate toolbar structure
if (toolbar=AllocVec(sizeof(ToolBarInfo),MEMF_CLEAR))
{
// Bank provided?
if (buttons) toolbar->buttons=buttons;
// Load disk file
else
if (pathname && pathname[0]) toolbar->buttons=OpenButtonBank(pathname);
// Invalid?
if (!toolbar->buttons ||
!(GetToolBarCache(toolbar,FALSE)))
{
FreeToolBar(toolbar);
return 0;
}
}
// Bank provided? Copy pathname
if (buttons && pathname)
strcpy(pathname,buttons->path);
return toolbar;
}
开发者ID:MrZammler,项目名称:opus_magellan,代码行数:31,代码来源:toolbar.c
示例16: SzFileReadImp
SRes SzFileReadImp(void *object, void *buffer, size_t *size)
{
CFileXadInStream *s = (CFileXadInStream *)object;
#ifdef __amigaos4__
struct xadMasterIFace *IxadMaster = s->IxadMaster;
#else
struct xadMasterBase *xadMasterBase = s->xadMasterBase;
#endif
if(!g_buffer) g_buffer = AllocVec(kBufferSize, MEMF_PRIVATE);
size_t processedSizeLoc =+ *size; // =+
//s->posn = processedSizeLoc;
if (*size > kBufferSize)
*size = kBufferSize;
if(xadHookAccess(XADAC_READ, *size, g_buffer, s->ai) != XADERR_OK)
return SZ_ERROR_FAIL;
memcpy(buffer, g_buffer, *size);
// *buffer = g_buffer;
/*
if (processedSize != 0)
*processedSize = processedSizeLoc;
*/
return SZ_OK;
}
开发者ID:BSzili,项目名称:aros-stuff,代码行数:29,代码来源:7z.c
示例17: AddUnit
static BOOL AddUnit(struct List *list, int unit) {
struct UnitNode *u;
u = AllocVec(sizeof(struct UnitNode), MEMF_CLEAR);
if(u == NULL) {
return FALSE;
}
u->prefs.ahiup_Unit = unit;
u->prefs.ahiup_Channels = 1;
u->prefs.ahiup_AudioMode = AHI_BestAudioID(AHIDB_Realtime, TRUE, TAG_DONE);
u->prefs.ahiup_Frequency = 8000;
u->prefs.ahiup_MonitorVolume = 0x00000;
u->prefs.ahiup_InputGain = 0x10000;
u->prefs.ahiup_OutputVolume = 0x10000;
u->prefs.ahiup_Input = 0;
u->prefs.ahiup_Output = 0;
FillUnitName(u);
u->node.ln_Pri = -unit;
Enqueue(list, (struct Node *) u);
return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:26,代码来源:support.c
示例18: InitSemaphore
struct MidiCluster *NewCluster(char *name,struct CamdBase *CamdBase){
struct MyMidiCluster *mymidicluster;
struct MidiCluster *midicluster;
mymidicluster=AllocMem(sizeof(struct MyMidiCluster),MEMF_ANY | MEMF_CLEAR | MEMF_PUBLIC);
if(mymidicluster==NULL) return NULL;
InitSemaphore(&mymidicluster->semaphore);
midicluster=&mymidicluster->cluster;
midicluster->mcl_Node.ln_Name=AllocVec(mystrlen(name) + 1,MEMF_ANY|MEMF_PUBLIC);
if(midicluster->mcl_Node.ln_Name==NULL){
FreeMem(midicluster,sizeof(struct MyMidiCluster));
return NULL;
}
mysprintf(CamdBase,midicluster->mcl_Node.ln_Name,"%s",name);
NEWLIST(&midicluster->mcl_Receivers);
NEWLIST(&midicluster->mcl_Senders);
AddTail(&CB(CamdBase)->midiclusters,&midicluster->mcl_Node);
return midicluster;
}
开发者ID:jgideonr,项目名称:camd,代码行数:30,代码来源:clusters.c
示例19: NameOfLock
/* Returns the lock of a name (Allocated with AllocVec()) */
STRPTR NameOfLock( BPTR lock )
{
STRPTR n;
BOOL again;
ULONG bufSize = 127;
if( !lock ) return NULL;
do
{
again = FALSE;
if((n = (STRPTR)AllocVec(bufSize, 0x10000 )))
{
if( NameFromLock( lock, n, bufSize-1 ) == DOSFALSE )
{
if( IoErr() == ERROR_LINE_TOO_LONG )
{
bufSize += 127;
again = TRUE;
}
FreeVec(n);
n = NULL;
}
}
} while(again);
return n;
}
开发者ID:sba1,项目名称:simplemail,代码行数:28,代码来源:amigasupport.c
示例20: CreateConnectionData
static void* CreateConnectionData(DBusConnection* connection) {
struct ConnectionData* c = AllocVec(sizeof(struct ConnectionData), MEMF_ANY|MEMF_CLEAR);
kprintf("CreateConnectionData %08lx\n", c);
if (c != NULL) {
c->connection = connection;
c->creator = FindTask(NULL);
NewList((struct List*) &c->watches);
Forbid();
kprintf("creating mainloop\n");
c->main = (struct Task*) CreateNewProcTags(NP_Entry, (ULONG) MainLoop,
NP_Name, (ULONG) "dbus.library main loop",
NP_Priority, 0,
TAG_DONE);
kprintf("created mainloop %08lx\n", c->main);
if (c->main != NULL) {
c->main->tc_UserData = c;
}
SetSignal(0, SIGF_SINGLE);
Permit();
Wait(SIGF_SINGLE);
if (c->main == NULL) {
DeleteConnectionData(c);
c = NULL;
}
}
return c;
}
开发者ID:michalsc,项目名称:AROS,代码行数:34,代码来源:dbus-amiga.c
注:本文中的AllocVec函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论