您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stalloc函数代码示例

51自学网 2021-06-03 08:21:25
  C++
这篇教程C++ stalloc函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中stalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ stalloc函数的具体用法?C++ stalloc怎么用?C++ stalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了stalloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pipeline

STATIC union node *pipeline() {      union node *n1, *pipenode;      struct nodelist *lp, *prev;      n1 = command();      if (readtoken() == TPIPE) {            pipenode = (union node *)stalloc(sizeof (struct npipe));            pipenode->type = NPIPE;            pipenode->npipe.backgnd = 0;            lp = (struct nodelist *)stalloc(sizeof (struct nodelist));            pipenode->npipe.cmdlist = lp;            lp->n = n1;            do {                  prev = lp;                  lp = (struct nodelist *)stalloc(sizeof (struct nodelist));                  lp->n = command();                  prev->next = lp;            } while (readtoken() == TPIPE);            lp->next = NULL;            n1 = pipenode;      }      tokpushback++;      return n1;}
开发者ID:hakan-akan,项目名称:cor,代码行数:25,


示例2:

/** * Initialize disk device driver. Reserves memory for data structures * and register driver to the interrupt handler. * * @param desc Pointer to the YAMS IO device descriptor of the disk * * @return Pointer to the device structure of the disk */device_t *disk_init(io_descriptor_t *desc) {  device_t *dev;  gbd_t    *gbd;  disk_real_device_t *real_dev;  uint32_t irq_mask;  dev = (device_t*)stalloc(sizeof(device_t));  gbd = (gbd_t*)stalloc(sizeof(gbd_t));  real_dev = (disk_real_device_t*)stalloc(sizeof(disk_real_device_t));  if (dev == NULL || gbd == NULL || real_dev == NULL)    KERNEL_PANIC("Could not allocate memory for disk driver.");  dev->generic_device = gbd;  dev->real_device = real_dev;  dev->descriptor = desc;  dev->io_address = desc->io_area_base;  dev->type = desc->type;  gbd->device = dev;  gbd->read_block = disk_read_block;  gbd->write_block = disk_write_block;  gbd->block_size = disk_block_size;  gbd->total_blocks = disk_total_blocks;  spinlock_reset(&real_dev->slock);  real_dev->request_queue = NULL;  real_dev->request_served = NULL;  irq_mask = 1 << (desc->irq + 10);  interrupt_register(irq_mask, disk_interrupt_handle, dev);  return dev;}
开发者ID:DIKU-EDU,项目名称:kudos,代码行数:41,


示例3: list

STATIC union node *list(nlflag) {      union node *n1, *n2, *n3;      checkkwd();      if (nlflag == 0 && tokendlist[lasttoken])            return NULL;      n1 = andor();      for (;;) {            switch (readtoken()) {            case TBACKGND:                  if (n1->type == NCMD || n1->type == NPIPE) {                        n1->ncmd.backgnd = 1;                  } else if (n1->type == NREDIR) {                        n1->type = NBACKGND;                  } else {                        n3 = (union node *)stalloc(sizeof (struct nredir));                        n3->type = NBACKGND;                        n3->nredir.n = n1;                        n3->nredir.redirect = NULL;                        n1 = n3;                  }                  goto tsemi;            case TNL:                  tokpushback++;                  /* fall through */tsemi:            case TSEMI:                  if (readtoken() == TNL) {                        parseheredoc();                        if (nlflag)                              return n1;                  } else {                        tokpushback++;                  }                  checkkwd();                  if (tokendlist[lasttoken])                        return n1;                  n2 = andor();                  n3 = (union node *)stalloc(sizeof (struct nbinary));                  n3->type = NSEMI;                  n3->nbinary.ch1 = n1;                  n3->nbinary.ch2 = n2;                  n1 = n3;                  break;            case TEOF:                  if (heredoclist)                        parseheredoc();                  else                        pungetc();                /* push back EOF on input */                  return n1;            default:                  if (nlflag)                        synexpect(-1);                  tokpushback++;                  return n1;            }      }}
开发者ID:hakan-akan,项目名称:cor,代码行数:58,


示例4: physmem_init

void physmem_init(void *boot_info){  multiboot_info_t *mb_info = (multiboot_info_t*)boot_info;  uint64_t *mem_ptr = (uint64_t*)(uint64_t)mb_info->memory_map_addr;  uint64_t Itr = 0, last_address = 0;  /* Setup Memory Stuff */  highest_page = 0;  memory_size = mb_info->memory_high;  memory_size += mb_info->memory_low;  total_blocks = (memory_size * 1024) / PAGE_SIZE;  used_blocks = total_blocks;  bitmap_size = total_blocks / PMM_BLOCKS_PER_BYTE;  _mem_bitmap = (uint64_t*)stalloc(bitmap_size);  physmem_lock = (spinlock_t*)stalloc(sizeof(spinlock_t));  spinlock_reset(physmem_lock);  /* Set all memory as used, and use memory map to set free */  memoryset(_mem_bitmap, 0xF, bitmap_size);  /* Physical Page Bitmap */  kprintf("Memory size: %u Kb/n", (uint32_t)memory_size);  /* Go through regions */  for(Itr = (uint64_t)mem_ptr;      Itr < ((uint64_t)mem_ptr + mb_info->memory_map_length);      )    {      /* Get next member */      mem_region_t *mem_region = (mem_region_t*)Itr;      /* Output */      //kprintf("Memory Region: Address 0x%xL, length 0x%xL, Type %u/n",      //        mem_region->base_address, mem_region->length, mem_region->Type);      /* Is it free? */      if(mem_region->type == MEMTYPE_FREE)        physmem_freeregion(mem_region->base_address,                           mem_region->length);      /* Advance by one structure */      Itr += sizeof(mem_region_t);    }  /* Mark all memory up to the static allocation point as used */  last_address = (physaddr_t)stalloc(1);  stalloc_disable();  for(Itr = physmem_allocblock(); Itr < last_address;)    Itr = physmem_allocblock();  /* Debug*/  kprintf("New memory allocation starts at 0x%xl/n", Itr);}
开发者ID:PtxDK,项目名称:OSM,代码行数:54,


示例5: KERNEL_PANIC

/** * Initializes interrupt driven tty driver. Memory is reserved for * data structures and tty interrupt handler is registerded. * * @param desc Pointer to a YAMS device descriptor data structure. * * @return Pointer to tty's device_t structure. */device_t *tty_init(io_descriptor_t *desc) {  device_t *dev;  gcd_t *gcd;  tty_real_device_t *tty_rd;  uint32_t irq_mask;  static int num_of_inits = 0;  dev = (device_t*)stalloc(sizeof(device_t));  if(dev == NULL)    KERNEL_PANIC("Could not reserve memory for tty driver.");  gcd = (gcd_t*)stalloc(sizeof(gcd_t));  if(gcd == NULL)    KERNEL_PANIC("Could not reserve memory for tty driver.");  dev->generic_device = gcd;  dev->io_address     = desc->io_area_base;  dev->type           = desc->type;  gcd->device = dev;  gcd->write  = tty_write;  gcd->read   = tty_read;  tty_rd = (tty_real_device_t*)stalloc(sizeof(tty_real_device_t));  if(tty_rd == NULL)    KERNEL_PANIC("Could not reserve memory for tty driver.");  dev->real_device = tty_rd;  if (num_of_inits == 0) {    /* First tty driver will share the device with the polling TTY.     * That is, we use the same spinlock with it. (The spinlock is     * kprintf's because that is the only proper way to access the     * polling tty.) */    tty_rd->slock = &kprintf_slock;  } else {    tty_rd->slock = (spinlock_t*)stalloc(sizeof(spinlock_t));    if(tty_rd->slock == NULL)      KERNEL_PANIC("Could not reserve memory for tty driver spinlock.");    spinlock_reset(tty_rd->slock);  }  num_of_inits++;  tty_rd->write_head = 0;  tty_rd->write_count = 0;  tty_rd->read_head = 0;  tty_rd->read_count = 0;  irq_mask = 1 << (desc->irq + 10);  interrupt_register(irq_mask, tty_interrupt_handle, dev);  return dev;}
开发者ID:DIKU-EDU,项目名称:kudos,代码行数:61,


示例6: addfname

STATIC voidaddfname(shinstance *psh, char *name){	char *p;	struct strlist *sp;	p = stalloc(psh, strlen(name) + 1);	scopy(name, p);	sp = (struct strlist *)stalloc(psh, sizeof *sp);	sp->text = p;	*psh->exparg.lastp = sp;	psh->exparg.lastp = &sp->next;}
开发者ID:egraba,项目名称:kbuild_openbsd,代码行数:13,


示例7: addfname

static voidaddfname(char *name){	char *p;	struct strlist *sp;	p = stalloc(strlen(name) + 1);	scopy(name, p);	sp = (struct strlist *)stalloc(sizeof *sp);	sp->text = p;	*exparg.lastp = sp;	exparg.lastp = &sp->next;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:13,


示例8: addfname

static voidaddfname(cstring_t name){    cstring_t p;    struct strlist* sp;    size_t len;    len = strlen(name);    p = stalloc(len + 1);    memcpy(p, name, len + 1);    sp = (struct strlist*)stalloc(sizeof * sp);    sp->text = p;    *exparg.lastp = sp;    exparg.lastp = &sp->next;}
开发者ID:ntposixdevs,项目名称:freebsdsh,代码行数:14,


示例9: physmem_init

/** * Physical memory initialization. Finds out number of physical pages and * number of staticly reserved physical pages. Marks reserved pages * reserved in physmem_free_pages. */void physmem_init(void *bootinfo){  int num_res_pages;  int i;  /* We dont use this */  bootinfo = bootinfo;  physmem_num_pages = physmem_get_size();  physmem_free_pages =    (uint32_t *)stalloc(bitmap_sizeof(physmem_num_pages));  bitmap_init(physmem_free_pages, physmem_num_pages);  /* Note that number of reserved pages must be get after we have     (staticly) reserved memory for bitmap. */  num_res_pages = physmem_get_reserved_size();  physmem_num_free_pages = physmem_num_pages - num_res_pages;  physmem_static_end = num_res_pages;  for (i = 0; i < num_res_pages; i++)    bitmap_set(physmem_free_pages, i, 1);  spinlock_reset(&physmem_slock);  kprintf("Physmem: Found %d pages of size %d/n", physmem_num_pages,          PAGE_SIZE);  kprintf("Physmem: Static allocation for kernel: %d pages/n",          num_res_pages);}
开发者ID:DIKU-EDU,项目名称:kudos,代码行数:35,


示例10: stalloc

static union node *alloc_node(struct parser *p, int type) {  union node *node;  node = stalloc(p->mark, sizeof(union node));  node->type = type;  return node;}
开发者ID:HarryR,项目名称:sanos,代码行数:7,


示例11: interrupt_init

/** Initializes interrupt handling. Allocates interrupt stacks for * each processor, initializes the interrupt vectors and initializes * the registered interrupt handler table. * * @param num_cpus Number of CPUs in the system */void interrupt_init(int num_cpus) {    int i;    uint32_t *iv_area1 = (uint32_t *)INTERRUPT_VECTOR_ADDRESS1;    uint32_t *iv_area2 = (uint32_t *)INTERRUPT_VECTOR_ADDRESS2;    uint32_t *iv_area3 = (uint32_t *)INTERRUPT_VECTOR_ADDRESS3;    uint32_t ret;    if (num_cpus < 1 || num_cpus > CONFIG_MAX_CPUS)        KERNEL_PANIC("Too few or many CPUs found");    /* Allocate interrupt stacks for each processor */    for(i = 0; i < num_cpus; i++) {        ret = (uint32_t)stalloc(PAGE_SIZE);        if (ret == 0)            KERNEL_PANIC("Unable to allocate interrupt stacks");        interrupt_stacks[i] = ret+PAGE_SIZE-4;    }    /* Copy the interrupt vector code to its positions.All vectors     * will contain the same code.     */    for(i = 0 ; i < INTERRUPT_VECTOR_LENGTH ; i++) {        iv_area1[i] = ((uint32_t *) (uintptr_t) &_cswitch_vector_code)[i];        iv_area2[i] = ((uint32_t *) (uintptr_t) &_cswitch_vector_code)[i];        iv_area3[i] = ((uint32_t *) (uintptr_t) &_cswitch_vector_code)[i];    }    /* Initialize the handler table to empty */    for (i=0; i<CONFIG_MAX_DEVICES; i++) {        interrupt_handlers[i].device = NULL;        interrupt_handlers[i].irq = 0;        interrupt_handlers[i].handler = NULL;    }}
开发者ID:kazyka,项目名称:2aar,代码行数:40,


示例12: padvance

char *padvance(const char **path, const char *name){	const char *p, *start;	char *q;	int len;	if (*path == NULL)		return NULL;	start = *path;	for (p = start; *p && *p != ':' && *p != '%'; p++)		; /* nothing */	len = p - start + strlen(name) + 2;	/* "2" is for '/' and '/0' */	while (stackblocksize() < len)		growstackblock();	q = stackblock();	if (p != start) {		memcpy(q, start, p - start);		q += p - start;		*q++ = '/';	}	strcpy(q, name);	pathopt = NULL;	if (*p == '%') {		pathopt = ++p;		while (*p && *p != ':')  p++;	}	if (*p == ':')		*path = p + 1;	else		*path = NULL;	return stalloc(len);}
开发者ID:grayshadow212,项目名称:usr.src,代码行数:33,


示例13: simplecmd

STATIC union node *simplecmd() {      union node *args, **app;      union node *redir, **rpp;      union node *n;      args = NULL;      app = &args;      rpp = &redir;      for (;;) {            if (readtoken() == TWORD) {                  n = (union node *)stalloc(sizeof (struct narg));                  n->type = NARG;                  n->narg.text = wordtext;                  n->narg.backquote = backquotelist;                  *app = n;                  app = &n->narg.next;            } else if (lasttoken == TREDIR) {                  *rpp = n = redirnode;                  rpp = &n->nfile.next;                  parsefname();        /* read name of redirection file */            } else if (lasttoken == TLP && app == &args->narg.next                                 && rpp == &redir) {                  /* We have a function */                  if (readtoken() != TRP)                        synexpect(TRP);                  if (! goodname(n->narg.text))                        synerror("Bad function name");                  n->type = NDEFUN;                  n->narg.next = command();                  return n;            } else {                  tokpushback++;                  break;            }      }      *app = NULL;      *rpp = NULL;      n = (union node *)stalloc(sizeof (struct ncmd));      n->type = NCMD;      n->ncmd.backgnd = 0;      n->ncmd.args = args;      n->ncmd.redirect = redir;      return n;}
开发者ID:hakan-akan,项目名称:cor,代码行数:45,


示例14: setstackmark

voidsetstackmark(struct stackmark *mark){	mark->stackp = stackp;	mark->stacknxt = stacknxt;	mark->stacknleft = stacknleft;	/* Ensure this block stays in place. */	if (stackp != NULL && stacknxt == SPACE(stackp))		stalloc(1);}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:10,


示例15: stsavestr

char *stsavestr(const char *s){	char *p;	size_t len;	len = strlen(s);	p = stalloc(len + 1);	memcpy(p, s, len + 1);	return p;}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:11,


示例16: growstackblock

static voidgrowstackblock(int min){	char *p;	int newlen;	char *oldspace;	int oldlen;	struct stack_block *sp;	struct stack_block *oldstackp;	struct stackmark *xmark;	if (min < stacknleft)		min = stacknleft;	if (min >= INT_MAX / 2 - ALIGN(sizeof(struct stack_block)))		error("Out of space");	min += stacknleft;	min += ALIGN(sizeof(struct stack_block));	newlen = 512;	while (newlen < min)		newlen <<= 1;	oldspace = stacknxt;	oldlen = stacknleft;	if (stackp != NULL && stacknxt == SPACE(stackp)) {		INTOFF;		oldstackp = stackp;		stackp = oldstackp->prev;		sp = ckrealloc((pointer)oldstackp, newlen);		sp->prev = stackp;		stackp = sp;		stacknxt = SPACE(sp);		stacknleft = newlen - (stacknxt - (char*)sp);		sstrend = stacknxt + stacknleft;		/*		 * Stack marks pointing to the start of the old block		 * must be relocated to point to the new block		 */		xmark = markp;		while (xmark != NULL && xmark->stackp == oldstackp) {			xmark->stackp = stackp;			xmark->stacknxt = stacknxt;			xmark->stacknleft = stacknleft;			xmark = xmark->marknext;		}		INTON;	} else {		newlen -= ALIGN(sizeof(struct stack_block));		p = stalloc(newlen);		if (oldlen != 0)			memcpy(p, oldspace, oldlen);		stunalloc(p);	}}
开发者ID:2014-class,项目名称:freerouter,代码行数:54,


示例17: expandarg

/* * Perform expansions on an argument, placing the resulting list of arguments * in arglist.  Parameter expansion, command substitution and arithmetic * expansion are always performed; additional expansions can be requested * via flag (EXP_*). * The result is left in the stack string. * When arglist is NULL, perform here document expansion. * * Caution: this function uses global state and is not reentrant. * However, a new invocation after an interrupted invocation is safe * and will reset the global state for the new call. */voidexpandarg(union node* arg, struct arglist* arglist, int32_t flag){    struct strlist* sp;    cstring_t p;    argbackq = arg->narg.backquote;    STARTSTACKSTR(expdest);    ifsfirst.next = NULL;    ifslastp = NULL;    argstr(arg->narg.text, flag);    if (arglist == NULL)    {        STACKSTRNUL(expdest);        return;			/* here document expanded */    }    STPUTC('/0', expdest);    p = grabstackstr(expdest);    exparg.lastp = &exparg.list;    /*     * TODO - EXP_REDIR     */    if (flag & EXP_FULL)    {        ifsbreakup(p, &exparg);        *exparg.lastp = NULL;        exparg.lastp = &exparg.list;        expandmeta(exparg.list, flag);    }    else    {        if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */            rmescapes(p);        sp = (struct strlist*)stalloc(sizeof(struct strlist));        sp->text = p;        *exparg.lastp = sp;        exparg.lastp = &sp->next;    }    while (ifsfirst.next != NULL)    {        pifsregion_t ifsp;        INTOFF;        ifsp = ifsfirst.next->next;        ckfree(ifsfirst.next);        ifsfirst.next = ifsp;        INTON;    }    *exparg.lastp = NULL;    if (exparg.list)    {        *arglist->lastp = exparg.list;        arglist->lastp = exparg.lastp;    }}
开发者ID:ntposixdevs,项目名称:freebsdsh,代码行数:65,


示例18: makename

STATIC union node *makename(void){	union node *n;	n = (union node *)stalloc(sizeof (struct narg));	n->type = NARG;	n->narg.next = NULL;	n->narg.text = wordtext;	n->narg.backquote = backquotelist;	return n;}
开发者ID:7shi,项目名称:minix-tools,代码行数:12,


示例19: pipeline

STATIC union node *pipeline(void){	union node *n1, *n2, *pipenode;	struct nodelist *lp, *prev;	int negate;	negate = 0;	TRACE(("pipeline: entered/n"));	while (readtoken() == TNOT)		negate = !negate;	tokpushback++;	n1 = command();	if (readtoken() == TPIPE) {		pipenode = (union node *)stalloc(sizeof (struct npipe));		pipenode->type = NPIPE;		pipenode->npipe.backgnd = 0;		lp = (struct nodelist *)stalloc(sizeof (struct nodelist));		pipenode->npipe.cmdlist = lp;		lp->n = n1;		do {			prev = lp;			lp = (struct nodelist *)stalloc(sizeof (struct nodelist));			lp->n = command();			prev->next = lp;		} while (readtoken() == TPIPE);		lp->next = NULL;		n1 = pipenode;	}	tokpushback++;	if (negate) {		n2 = (union node *)stalloc(sizeof (struct nnot));		n2->type = NNOT;		n2->nnot.com = n1;		return n2;	} else		return n1;}
开发者ID:7shi,项目名称:minix-tools,代码行数:38,


示例20: parsefname

STATIC voidparsefname() {      union node *n = redirnode;      if (readtoken() != TWORD)            synexpect(-1);      if (n->type == NHERE) {            struct heredoc *here = heredoc;            struct heredoc *p;            int i;            if (quoteflag == 0)                  n->type = NXHERE;            TRACE(("Here document %d/n", n->type));            if (here->striptabs) {                  while (*wordtext == '/t')                        wordtext++;            }            if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN)                  synerror("Illegal eof marker for << redirection");            rmescapes(wordtext);            here->eofmark = wordtext;            here->next = NULL;            if (heredoclist == NULL)                  heredoclist = here;            else {                  for (p = heredoclist ; p->next ; p = p->next);                  p->next = here;            }      } else if (n->type == NTOFD || n->type == NFROMFD) {            if (is_digit(wordtext[0]))                  n->ndup.dupfd = digit_val(wordtext[0]);            else if (wordtext[0] == '-')                  n->ndup.dupfd = -1;            else                  goto bad;            if (wordtext[1] != '/0') {bad:                  synerror("Bad fd number");            }      } else {            n->nfile.fname = (union node *)stalloc(sizeof (struct narg));            n = n->nfile.fname;            n->type = NARG;            n->narg.next = NULL;            n->narg.text = wordtext;            n->narg.backquote = backquotelist;      }}
开发者ID:hakan-akan,项目名称:cor,代码行数:49,


示例21:

/* A helper to the init functions. Fills the given device structure to * values from the given IO descriptor and uses "null" values for the * rest. Allocates memory for the structure if it was given as NULL */static device_t *fill_device_t(io_descriptor_t *desc, device_t *dev){  if (dev == NULL)    dev = (device_t*)stalloc(sizeof(device_t));  if (dev == NULL)    KERNEL_PANIC("Run out ouf memory when allocating struct"                 " for a metadevice");  dev->real_device = NULL;  dev->generic_device = NULL;  dev->descriptor = desc;  dev->io_address = desc->io_area_base;  dev->type = desc->type;  return dev;}
开发者ID:DIKU-EDU,项目名称:kudos,代码行数:20,


示例22: growstackblock

voidgrowstackblock(void){	char *p;	int newlen;	char *oldspace;	int oldlen;	struct stack_block *sp;	struct stack_block *oldstackp;	struct stackmark *xmark;	newlen = (stacknleft == 0) ? MINSIZE : stacknleft * 2 + 100;	newlen = ALIGN(newlen);	oldspace = stacknxt;	oldlen = stacknleft;	if (stackp != NULL && stacknxt == SPACE(stackp)) {		INTOFF;		oldstackp = stackp;		stackp = oldstackp->prev;		sp = ckrealloc((pointer)oldstackp, newlen);		sp->prev = stackp;		stackp = sp;		stacknxt = SPACE(sp);		stacknleft = newlen - (stacknxt - (char*)sp);		/*		 * Stack marks pointing to the start of the old block		 * must be relocated to point to the new block		 */		xmark = markp;		while (xmark != NULL && xmark->stackp == oldstackp) {			xmark->stackp = stackp;			xmark->stacknxt = stacknxt;			xmark->stacknleft = stacknleft;			xmark = xmark->marknext;		}		INTON;	} else {		p = stalloc(newlen);		if (oldlen != 0)			memcpy(p, oldspace, oldlen);		stunalloc(p);	}}
开发者ID:QiuLihua83,项目名称:minix2009,代码行数:45,


示例23: appendarglist

voidappendarglist(struct arglist *list, char *str){	char **newargs;	int newcapacity;	if (list->count >= list->capacity) {		newcapacity = list->capacity * 2;		if (newcapacity < 16)			newcapacity = 16;		if (newcapacity > INT_MAX / (int)sizeof(newargs[0]))			error("Too many entries in arglist");		newargs = stalloc(newcapacity * sizeof(newargs[0]));		memcpy(newargs, list->args, list->count * sizeof(newargs[0]));		list->args = newargs;		list->capacity = newcapacity;	}	list->args[list->count++] = str;}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:19,


示例24: expandarg

/* * Perform expansions on an argument, placing the resulting list of arguments * in arglist.  Parameter expansion, command substitution and arithmetic * expansion are always performed; additional expansions can be requested * via flag (EXP_*). * The result is left in the stack string. * When arglist is NULL, perform here document expansion. * * Caution: this function uses global state and is not reentrant. * However, a new invocation after an interrupted invocation is safe * and will reset the global state for the new call. */voidexpandarg(union node *arg, struct arglist *arglist, int flag){	struct strlist *sp;	char *p;	argbackq = arg->narg.backquote;	STARTSTACKSTR(expdest);	ifsfirst.next = NULL;	ifslastp = NULL;	argstr(arg->narg.text, flag);	if (arglist == NULL) {		STACKSTRNUL(expdest);		return;			/* here document expanded */	}	STPUTC('/0', expdest);	p = grabstackstr(expdest);	exparg.lastp = &exparg.list;	if (flag & EXP_FULL) {		ifsbreakup(p, &exparg);		*exparg.lastp = NULL;		exparg.lastp = &exparg.list;		expandmeta(exparg.list);	} else {		sp = (struct strlist *)stalloc(sizeof (struct strlist));		sp->text = p;		*exparg.lastp = sp;		exparg.lastp = &sp->next;	}	while (ifsfirst.next != NULL) {		struct ifsregion *ifsp;		INTOFF;		ifsp = ifsfirst.next->next;		ckfree(ifsfirst.next);		ifsfirst.next = ifsp;		INTON;	}	*exparg.lastp = NULL;	if (exparg.list) {		*arglist->lastp = exparg.list;		arglist->lastp = exparg.lastp;	}}
开发者ID:DragonFlyBSD,项目名称:DragonFlyBSD,代码行数:55,


示例25: physmem_get_reserved_size

/** * Returns the number of pages statically reserved for the kernel. * * @return The number of pages */int physmem_get_reserved_size(){  int num_res_pages;  uint32_t system_memory_size = 0;  physaddr_t free_start = (physaddr_t)stalloc(1);  system_memory_size = physmem_get_size() * PAGE_SIZE;  num_res_pages = (free_start - 0x80000000) / PAGE_SIZE;  if (((free_start - 0x80000000) % PAGE_SIZE) != 0)    num_res_pages++;  kprintf("Kernel size is 0x%.8x (%d) bytes/n",          (free_start - KERNEL_BOOT_ADDRESS),          (free_start - KERNEL_BOOT_ADDRESS));  kprintf("System Memory Size: 0x%x bytes/n", system_memory_size);  return num_res_pages;}
开发者ID:DIKU-EDU,项目名称:kudos,代码行数:24,


示例26: growstackblock

voidgrowstackblock(void){	int newlen = SHELL_ALIGN(stacknleft * 2 + 100);	if (stacknxt == stackp->space && stackp != &stackbase) {		struct stack_block *oldstackp;		struct stackmark *xmark;		struct stack_block *sp;		INTOFF;		oldstackp = stackp;		sp = stackp;		stackp = sp->prev;		sp = ckrealloc((pointer)sp,		    sizeof(struct stack_block) - MINSIZE + newlen);		sp->prev = stackp;		stackp = sp;		stacknxt = sp->space;		stacknleft = newlen;		/*		 * Stack marks pointing to the start of the old block		 * must be relocated to point to the new block 		 */		xmark = markp;		while (xmark != NULL && xmark->stackp == oldstackp) {			xmark->stackp = stackp;			xmark->stacknxt = stacknxt;			xmark->stacknleft = stacknleft;			xmark = xmark->marknext;		}		INTON;	} else {		char *oldspace = stacknxt;		int oldlen = stacknleft;		char *p = stalloc(newlen);		(void)memcpy(p, oldspace, oldlen);		stacknxt = p;			/* free the space */		stacknleft += newlen;		/* we just allocated */	}}
开发者ID:skrll,项目名称:netbsd-src,代码行数:43,


示例27: growstackblock

static voidgrowstackblock(int min){	char *p;	int newlen;	char *oldspace;	int oldlen;	struct stack_block *sp;	struct stack_block *oldstackp;	if (min < stacknleft)		min = stacknleft;	if ((unsigned int)min >=	    INT_MAX / 2 - ALIGN(sizeof(struct stack_block)))		error("Out of space");	min += stacknleft;	min += ALIGN(sizeof(struct stack_block));	newlen = 512;	while (newlen < min)		newlen <<= 1;	oldspace = stacknxt;	oldlen = stacknleft;	if (stackp != NULL && stacknxt == SPACE(stackp)) {		INTOFF;		oldstackp = stackp;		stackp = oldstackp->prev;		sp = ckrealloc((pointer)oldstackp, newlen);		sp->prev = stackp;		stackp = sp;		stacknxt = SPACE(sp);		stacknleft = newlen - (stacknxt - (char*)sp);		sstrend = stacknxt + stacknleft;		INTON;	} else {		newlen -= ALIGN(sizeof(struct stack_block));		p = stalloc(newlen);		if (oldlen != 0)			memcpy(p, oldspace, oldlen);		stunalloc(p);	}}
开发者ID:0xffffffRabbit,项目名称:NextBSD-1,代码行数:42,


示例28: fill_device_t

/** Initializes a CPU status device. These devices are currently used * for detecting the total number of CPUs in the system. In addition * to this a mechanism for generating interrupts on the CPU is * supported. * * @param desc Pointer to the YAMS IO device descriptor of the CPU * status device  * * @return Pointer to the device structure of the CPU status device */device_t *cpustatus_init(io_descriptor_t *desc){  device_t *dev;  cpu_real_device_t *cpu;  uint32_t irq_mask;  dev = fill_device_t(desc, NULL);  cpu = (cpu_real_device_t*)stalloc(sizeof(cpu_real_device_t));  if (cpu == NULL)     KERNEL_PANIC("Could not reserve memory for CPU status device driver.");  spinlock_reset(&cpu->slock);  dev->real_device = cpu;  irq_mask = 1 << (desc->irq + 10);  interrupt_register(irq_mask, cpustatus_interrupt_handle, dev);  return dev;}
开发者ID:DIKU-EDU,项目名称:kudos,代码行数:30,


示例29: sym_addr

byte * sym_addr(char * s, int * c, int * v){  symbol * h = head;  symbol * n;  /* fprintf(stderr, "fetching %s/n", s); */  while(h != NULL)  {    if(!strcmp(s, h->id))    {      *c = h->constant;      *v = h->value;      return h->addr;    }    h = h->next;  }  /* fprintf(stderr, "Creating %s/n", s); */  n = (symbol *)malloc(sizeof(symbol));  /* fprintf(stderr, "Malloc'ed n/n"); */  if (n == NULL)  {    fprintf(stderr, "Could not allocate symbol table record/n");  } else  {    n->id = (char *)malloc(strlen(s)+1);    if (n->id == NULL)    {      fprintf(stderr, "Could not allocate lexeme/n");    } else    {      /* fprintf(stderr, "Copying %s to n->id/n", s); */      strcpy(n->id, s);      n->addr = stalloc(2);      n->constant = *c;      n->value = *v;      n->next = head;      head = n;      return n->addr;    }  }  return NULL;}
开发者ID:catseye,项目名称:Illgol-Grand-Mal,代码行数:41,


示例30: expandarg

voidexpandarg(shinstance *psh, union node *arg, struct arglist *arglist, int flag){	struct strlist *sp;	char *p;	psh->argbackq = arg->narg.backquote;	STARTSTACKSTR(psh, psh->expdest);	psh->ifsfirst.next = NULL;	psh->ifslastp = NULL;	argstr(psh, arg->narg.text, flag);	if (arglist == NULL) {		return;			/* here document expanded */	}	STPUTC(psh, '/0', psh->expdest);	p = grabstackstr(psh, psh->expdest);	TRACE2((psh, "expandarg: p='%s'/n", p));	psh->exparg.lastp = &psh->exparg.list;	/*	 * TODO - EXP_REDIR	 */	if (flag & EXP_FULL) {		ifsbreakup(psh, p, &psh->exparg);		*psh->exparg.lastp = NULL;		psh->exparg.lastp = &psh->exparg.list;		expandmeta(psh, psh->exparg.list, flag);	} else {		if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */			rmescapes(psh, p);		sp = (struct strlist *)stalloc(psh, sizeof (struct strlist));		sp->text = p;		*psh->exparg.lastp = sp;		psh->exparg.lastp = &sp->next;	}	ifsfree(psh);	*psh->exparg.lastp = NULL;	if (psh->exparg.list) {		*arglist->lastp = psh->exparg.list;		arglist->lastp = psh->exparg.lastp;	}}
开发者ID:egraba,项目名称:kbuild_openbsd,代码行数:41,



注:本文中的stalloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ standend函数代码示例
C++ staffIdx函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。