本文整理匯總了C++中AllocVec函數的典型用法代碼示例。如果您正苦於以下問題:C++ AllocVec函數的具體用法?C++ AllocVec怎麽用?C++ AllocVec使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AllocVec函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}