当前位置: 首页>>代码示例>>C++>>正文


C++ KMALLOC函数代码示例

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


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

示例1: env_setenv

int env_setenv(const char *name,char *value,int flags)
{
    cfe_envvar_t *env;
    int namelen;

    env = env_findenv(name);
    if (env) {
	if (!(flags & ENV_FLG_ADMIN)) {
	    if (env->flags & ENV_FLG_READONLY) return CFE_ERR_ENVREADONLY;
	    }
	q_dequeue((queue_t *) env);
	KFREE(env);
	}

    namelen = strlen(name);

    env = KMALLOC(sizeof(cfe_envvar_t) + namelen + 1 + strlen(value) + 1,0);
    if (!env) return CFE_ERR_NOMEM;

    env->name = (char *) (env+1);
    env->value = env->name + namelen + 1;
    env->flags = (flags & ENV_FLG_MASK);

    strcpy(env->name,name);
    strcpy(env->value,value);

    q_enqueue(&env_envvars,(queue_t *) env);

    return 0;
}
开发者ID:Noltari,项目名称:cfe_bcm63xx,代码行数:30,代码来源:env_subr.c

示例2: do_execute_java_class_method_v

/**
 * Call a Java static method on a class from native code.
 *
 * @param cname name of the class whose method is to be called
 * @param loader the class loader that's to be used to lookup the class
 * @param method_name the name of the method to be called
 * @param signature the signature of the method to be called
 * @param argptr the arguments to be passed to the method
 *
 * @throws NuSuchMethodError if method cannot be found
 * 
 * @return the return value of the method
 */
void
do_execute_java_class_method_v(jvalue *retval, const char* cname,
	Hjava_lang_ClassLoader* loader, const char* method_name,
	const char* signature, va_list argptr)
{
	Hjava_lang_Class* clazz;
	errorInfo info;
	Method* mb = NULL;
	char *buf;

	/* Convert "." to "/" and lookup class */
	buf = checkPtr(KMALLOC(strlen(cname) + 1));
	classname2pathname(cname, buf);
	clazz = lookupClass(buf, loader, &info);
	KFREE(buf);

	/* Get method */
	if (clazz != NULL) {
		mb = lookupClassMethod(clazz, method_name, signature, false, &info);
	}
	if (mb == NULL) {
		throwError(&info);
	}

	/* Method must be static to invoke it here */
	if ((mb->accflags & ACC_STATIC) == 0) {
		throwException(NoSuchMethodError(method_name));
	}

	/* Make the call */
	KaffeVM_callMethodV(mb, METHOD_NATIVECODE(mb), NULL, argptr, retval);
}
开发者ID:BillTheBest,项目名称:kaffe,代码行数:45,代码来源:support.c

示例3: pcconsole_probe

static void pcconsole_probe(cfe_driver_t *drv,
			      unsigned long probe_a, unsigned long probe_b, 
			      void *probe_ptr)
{
    pcconsole_t *softc;
    char descr[80];

    /* 
     * probe_a is
     * probe_b is     
     * probe_ptr is 
     */

    softc = (pcconsole_t *) KMALLOC(sizeof(pcconsole_t),0);
    if (softc) {

	memset(softc,0,sizeof(pcconsole_t));

	vga_init(&(softc->vga),__ISAaddr(VGA_TEXTBUF_COLOR),outb);

	xsprintf(descr,"%s",drv->drv_description,probe_a,probe_b);
	cfe_attach(drv,softc,NULL,descr);
	}

}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:25,代码来源:dev_pcconsole2.c

示例4: cfe_attach_idx

int cfe_attach_idx(cfe_driver_t *drv,int idx,void *softc,
		   char *bootinfo,char *description)
{
    char name[64];
    cfe_device_t *dev;

    xsprintf(name,"%s%d",drv->drv_bootname,idx);

    if (bootinfo) {
	strcat(name,".");
	strcat(name,bootinfo);
	}

    if (cfe_finddev(name) != NULL) {
	return 0;
	}

    dev = (cfe_device_t *) KMALLOC(sizeof(cfe_device_t),0);
    if (!dev) return -1;

    dev->dev_fullname = strdup(name);
    dev->dev_softc = softc;
    dev->dev_class = drv->drv_class;
    dev->dev_dispatch = drv->drv_dispatch;
    dev->dev_description = description ? strdup(description) : NULL;
    dev->dev_opencount = 0;

    q_enqueue(&cfe_devices,(queue_t *) dev);

    return 1;

}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:32,代码来源:cfe_attach.c

示例5: assert

struct debug_file *createDebugFile(const char *filename)
{
	struct debug_file *retval = 0;

	assert(filename != NULL);
	
	/* Allocate space for the debug_file struct and filename */
	if( (retval = (struct debug_file *)
	     KMALLOC(sizeof(struct debug_file) + strlen(filename) + 1)) )
	{
		retval->df_filename = (char *)(retval + 1);
		strcpy(retval->df_filename, filename);
		retval->df_current_type_id = STYPE_MAX;
		if( (retval->df_file = fopen(retval->df_filename, "w")) )
		{
			addDebugInfo(retval,
				     DIA_SourceFile, "$xdb$.java", 0,
				     DIA_Comment, debug_header,
				     DIA_DONE);
			fprintf(retval->df_file, "%s", types_header);
		}
		else
		{
			KFREE(retval);
			retval = 0;
		}
	}
	return( retval );
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:29,代码来源:debugFile.c

示例6: sb1250_uart_probe

static void sb1250_uart_probe(cfe_driver_t *drv,
			      unsigned long probe_a, unsigned long probe_b, 
			      void *probe_ptr)
{
    sb1250_uart_t *softc;
    char descr[80];

    /* 
     * probe_a is the DUART base address.
     * probe_b is the channel-number-within-duart (0 or 1)
     * probe_ptr is unused.
     */

    softc = (sb1250_uart_t *) KMALLOC(sizeof(sb1250_uart_t),0);
    if (softc) {
	softc->uart_mode_reg_1 = probe_a + R_DUART_CHANREG(probe_b,R_DUART_MODE_REG_1);
	softc->uart_mode_reg_2 = probe_a + R_DUART_CHANREG(probe_b,R_DUART_MODE_REG_2);
	softc->uart_clk_sel    = probe_a + R_DUART_CHANREG(probe_b,R_DUART_CLK_SEL);
	softc->uart_cmd        = probe_a + R_DUART_CHANREG(probe_b,R_DUART_CMD);
	softc->uart_status     = probe_a + R_DUART_CHANREG(probe_b,R_DUART_STATUS);
	softc->uart_tx_hold    = probe_a + R_DUART_CHANREG(probe_b,R_DUART_TX_HOLD);
	softc->uart_rx_hold    = probe_a + R_DUART_CHANREG(probe_b,R_DUART_RX_HOLD);	
	softc->uart_imr        = probe_a + R_DUART_IMRREG(probe_b);
	softc->uart_oprset     = probe_a + R_DUART_SET_OPR;
	xsprintf(descr,"%s at 0x%X channel %d",drv->drv_description,probe_a,probe_b);
	softc->uart_speed = CFG_SERIAL_BAUD_RATE;
	softc->uart_flowcontrol = SERIAL_FLOW_NONE;
    
	cfe_attach(drv,softc,NULL,descr);
	}

}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:32,代码来源:dev_sb1250_uart.c

示例7: memory_fileop_open

/* filename describes the location in memory in string */
static int memory_fileop_open(void **ref, void *fsctx_arg, char *filename, int mode)
{
	memory_fsctx_t *fsctx;
	memory_file_t *file;

	if (mode != FILE_MODE_READ)
	    return CFE_ERR_UNSUPPORTED;

	fsctx = (memory_fsctx_t *) fsctx_arg;

	file = KMALLOC(sizeof(memory_file_t), 0);
	if (!file) {
		return CFE_ERR_NOMEM;
	}

	if (filename[0] == ':')
		filename++; /* Skip over colon */

	file->memory_start = xtoi(filename);

	file->memory_offset = 0;

	*ref = file;
	return 0;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:26,代码来源:cfe_memfs.c

示例8: setupSigAltStack

static void
setupSigAltStack(void)
{
        STACK_STRUCT newstack;
	void *stackp;

	/*
	 * Signals has to have their own stack so we can solve
	 * stack problems.
	 */
	newstack.ss_size = THREADSTACKSIZE;
	newstack.ss_flags = 0;
	stackp = KMALLOC(newstack.ss_size);
#if defined(SIGALTSTACK_NEEDS_END)
	newstack.ss_sp = (void *)((uintp)stackp + newstack.ss_size);
#else
	newstack.ss_sp = stackp;
#endif
	if (sigaltstack(&newstack, NULL) < 0)
	  {
	    dprintf("Unexpected error calling sigaltstack: %s\n",
		    SYS_ERROR(errno));
	    KAFFEVM_EXIT(1);
	  }
}
开发者ID:BillTheBest,项目名称:kaffe,代码行数:25,代码来源:signal.c

示例9: comm_open

static
LONG
CDECL
comm_open(FILEPTR * f)
{
  char deb[100];

  NOT_USED(f);


  /* Create and initialize internal file handle */
  FH(f) = (LONG)KMALLOC(sizeof(FileHandle));
  
  FH(f)->bytes_out = 0;
  FH(f)->selected = 0;
  FH(f)->queued = 0;

  SPRINTF(deb,
          "srv_comm_device: open: devinfo = 0x%lx, f = 0x%lx",
          f->devinfo,
          f);
  TRACE(deb);

  return 0;
}
开发者ID:e8johan,项目名称:oaesis,代码行数:25,代码来源:srv_comm_device.c

示例10: flashdrv_open

static int flashdrv_open(cfe_devctx_t *ctx)
{
    flashpart_t *part = ctx->dev_softc;
    flashdev_t *softc = part->fp_dev;
    int ttlsect = softc->fd_ttlsect;

    /*
     * Calculate number of flashop instructions we'll need at most. 
     * This will be two for each sector plus two more for the first 
     * and last sectors, plus two extra
     */

    ttlsect = (ttlsect * 2 * softc->fd_probe.flash_nchips) + 6;

    /*
     * Allocate memory for instructions.
     */

#ifdef _NEWFLASH_DEBUG_
    printf("%s: allocating %d instructions\n",cfe_device_name(ctx),ttlsect);
#endif

    softc->fd_inst = KMALLOC(ttlsect*sizeof(flashinstr_t),0);
    if (!softc->fd_inst) return CFE_ERR_NOMEM;

    return 0;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:27,代码来源:dev_newflash.c

示例11: raw_fileop_init

static int raw_fileop_init(void **newfsctx,void *dev)
{
    raw_fsctx_t *fsctx;
    char *devicename = (char *) dev;

    *newfsctx = NULL;

    fsctx = KMALLOC(sizeof(raw_fsctx_t),0);
    if (!fsctx) {
	return CFE_ERR_NOMEM;
	}

    if (strcmp(devicename,console_name) == 0) {	
	fsctx->raw_dev = console_handle;
	fsctx->raw_isconsole = TRUE;
	}
    else {
	fsctx->raw_dev = cfe_open(devicename);
	fsctx->raw_isconsole = FALSE;
	}

    fsctx->raw_refcnt = 0;

    if (fsctx->raw_dev >= 0) {
	*newfsctx = fsctx;
	return 0;
	}

    KFREE(fsctx);

    return CFE_ERR_FILENOTFOUND;
}
开发者ID:Noltari,项目名称:cfe_bcm63xx,代码行数:32,代码来源:cfe_rawfs.c

示例12: cmd_eat_leading_white

ui_command_t *cmd_readcommand(queue_t *head)
{
    char *ptr;
    int insquote = FALSE;
    int indquote = FALSE;
    ui_command_t *cmd;
    int term = CMD_TERM_EOL;
    ui_token_t *t;

    cmd_eat_leading_white(head);

    if (q_isempty(head)) return NULL;

    cmd = (ui_command_t *) KMALLOC(sizeof(ui_command_t),0);
    q_init(&(cmd->head));

    while ((t = (ui_token_t *) q_deqnext(head))) {

	ptr = &(t->token);

	if (!insquote && !indquote) {
	    if ((*ptr == ';') || (*ptr == '\n')) {
		term = CMD_TERM_SEMI;
		break;
		}	
	    if ((*ptr == '&') && (*(ptr+1) == '&')) {
		term = CMD_TERM_AND;
		break;
		}
	    if ((*ptr == '|') && (*(ptr+1) == '|')) {
		term = CMD_TERM_OR;
		break;
		}
	    }

	if (*ptr == '\'') {
	    insquote = !insquote;
	    }

	if (!insquote) {
	    if (*ptr == '"') {
		indquote = !indquote;
		}
	    }

	q_enqueue(&(cmd->head),&(t->qb));
		
	}

    cmd->term = term;

    /* If we got out by finding a command separator, eat the separator */
    if (term != CMD_TERM_EOL) {
	KFREE(t);
	}

    return cmd;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:58,代码来源:ui_command.c

示例13: env_save

int env_save(void)
{
    int size;
    unsigned char *buffer;
    unsigned char *buffer_end;
    unsigned char *ptr;
    queue_t *qb;
    cfe_envvar_t *env;
    int namelen;
    int valuelen;
    int flg;

    flg = nvram_open();
    if (flg < 0) return flg;

    nvram_erase();

    size = nvram_getsize();
    buffer = KMALLOC(size,0);

    if (buffer == NULL) return CFE_ERR_NOMEM;

    buffer_end = buffer + size;

    ptr = buffer;

    for (qb = env_envvars.q_next; qb != &env_envvars; qb = qb->q_next) {
	env = (cfe_envvar_t *) qb;

	if (env->flags & (ENV_FLG_BUILTIN)) continue;

	namelen = strlen(env->name);
	valuelen = strlen(env->value);

	if ((ptr + 2 + namelen + valuelen + 1 + 1 + 1) > buffer_end) break;

	*ptr++ = ENV_TLV_TYPE_ENV;		/* TLV record type */
	*ptr++ = (namelen + valuelen + 1 + 1);	/* TLV record length */

	*ptr++ = (unsigned char)env->flags;
	memcpy(ptr,env->name,namelen);		/* TLV record data */
	ptr += namelen;
	*ptr++ = '=';
	memcpy(ptr,env->value,valuelen);
	ptr += valuelen;

	}

    *ptr++ = ENV_TLV_TYPE_END;

    size = nvram_write(buffer,0,ptr-buffer);

    KFREE(buffer);

    nvram_close();

    return (size == (ptr-buffer)) ? 0 : CFE_ERR_IOERR;
}
开发者ID:Noltari,项目名称:cfe_bcm63xx,代码行数:58,代码来源:env_subr.c

示例14: KMALLOC

static ui_token_t *make_token(char *str,int len)
{
    ui_token_t *t = (ui_token_t *) KMALLOC(sizeof(ui_token_t) + len,0);

    memcpy(&(t->token),str,len);
    (&(t->token))[len] = 0;

    return t;
}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:9,代码来源:ui_command.c

示例15: tftp_fileop_open

static int tftp_fileop_open(void **ref,void *fsctx,char *filename,int mode)
{
    tftp_info_t *info;
    char *host;
    char *file;
    int res;

    if ((mode != FILE_MODE_READ) && (mode != FILE_MODE_WRITE)) {
	/* must be either read or write, not both */
	return CFE_ERR_UNSUPPORTED;
	}

    /* Allocate the tftp info structure */

    info = KMALLOC(sizeof(tftp_info_t),0);
    if (!info) {
	return CFE_ERR_NOMEM;
	}


    info->tftp_filename = lib_strdup(filename);
    if (!info->tftp_filename) {
	KFREE(info);
	return CFE_ERR_NOMEM;
	}

    lib_chop_filename(info->tftp_filename,&host,&file);

    /* Open the file */

    if (!*host && !*file) {
	/* TFTP server if hostname and filename are not specified */
#ifdef RESCUE_MODE
        xprintf("TFTP Server.\n");
#endif
	res = _tftpd_open(info,host,file,mode);
    } else {
	/* TFTP client otherwise */
#ifdef RESCUE_MODE
        xprintf("TFTP Client.\n");
#endif
	res = _tftp_open(info,host,file,mode);
    }

    if (res == 0) {
	info->tftp_blkoffset = 0;
	info->tftp_fileoffset = 0;
	*ref = info;
	}
    else {
	KFREE(info->tftp_filename);
	KFREE(info);
	*ref = NULL;
	}
    return res;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:56,代码来源:net_tftp.c


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