本文整理汇总了C++中qemu_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ qemu_malloc函数的具体用法?C++ qemu_malloc怎么用?C++ qemu_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qemu_malloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: android_charmap_setup
int
android_charmap_setup(const char* kcm_file_path) {
// android_charmap_count being non-zero is used here as a flag,
// indicating that charmap has been initialized for the running
// executable.
if (android_charmap_count != 0) {
return 0;
}
if (NULL != kcm_file_path) {
if (!parse_kcm_file(kcm_file_path, &android_custom_charmap)) {
// Here we have two default charmaps and the custom one.
android_charmap_count = 3;
android_charmaps = qemu_malloc(sizeof(AKeyCharmap*) *
android_charmap_count);
android_charmaps[0] = &android_custom_charmap;
android_charmaps[1] = &_qwerty_charmap;
android_charmaps[2] = &_qwerty2_charmap;
} else {
derror("Unable to parse kcm file.");
return -1;
}
} else {
// Here we have only two default charmaps.
android_charmap_count = 2;
android_charmaps = qemu_malloc(sizeof(AKeyCharmap*) *
android_charmap_count);
android_charmaps[0] = &_qwerty_charmap;
android_charmaps[1] = &_qwerty2_charmap;
}
return 0;
}
开发者ID:Andproject,项目名称:platform_external_qemu,代码行数:33,代码来源:charmap.c
示例2: android_charmap_setup
int
android_charmap_setup(const char* kcm_file_path) {
if (NULL != kcm_file_path) {
if (!parse_kcm_file(kcm_file_path, &android_custom_charmap)) {
// Here we have two default charmaps and the custom one.
android_charmap_count = 3;
android_charmaps = qemu_malloc(sizeof(AKeyCharmap*) *
android_charmap_count);
android_charmaps[0] = &android_custom_charmap;
android_charmaps[1] = &_qwerty_charmap;
android_charmaps[2] = &_qwerty2_charmap;
} else {
derror("Unable to parse kcm file.");
return -1;
}
} else {
// Here we have only two default charmaps.
android_charmap_count = 2;
android_charmaps = qemu_malloc(sizeof(AKeyCharmap*) *
android_charmap_count);
android_charmaps[0] = &_qwerty_charmap;
android_charmaps[1] = &_qwerty2_charmap;
}
return 0;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:26,代码来源:charmap.c
示例3: qcow2_read_snapshots
int qcow2_read_snapshots(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshotHeader h;
QCowSnapshot *sn;
int i, id_str_size, name_size;
int64_t offset;
uint32_t extra_data_size;
if (!s->nb_snapshots) {
s->snapshots = NULL;
s->snapshots_size = 0;
return 0;
}
offset = s->snapshots_offset;
s->snapshots = qemu_mallocz(s->nb_snapshots * sizeof(QCowSnapshot));
for(i = 0; i < s->nb_snapshots; i++) {
offset = align_offset(offset, 8);
if (bdrv_pread(s->hd, offset, &h, sizeof(h)) != sizeof(h))
goto fail;
offset += sizeof(h);
sn = s->snapshots + i;
sn->l1_table_offset = be64_to_cpu(h.l1_table_offset);
sn->l1_size = be32_to_cpu(h.l1_size);
sn->vm_state_size = be32_to_cpu(h.vm_state_size);
sn->date_sec = be32_to_cpu(h.date_sec);
sn->date_nsec = be32_to_cpu(h.date_nsec);
sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec);
extra_data_size = be32_to_cpu(h.extra_data_size);
id_str_size = be16_to_cpu(h.id_str_size);
name_size = be16_to_cpu(h.name_size);
offset += extra_data_size;
sn->id_str = qemu_malloc(id_str_size + 1);
if (bdrv_pread(s->hd, offset, sn->id_str, id_str_size) != id_str_size)
goto fail;
offset += id_str_size;
sn->id_str[id_str_size] = '\0';
sn->name = qemu_malloc(name_size + 1);
if (bdrv_pread(s->hd, offset, sn->name, name_size) != name_size)
goto fail;
offset += name_size;
sn->name[name_size] = '\0';
}
s->snapshots_size = offset - s->snapshots_offset;
return 0;
fail:
qcow2_free_snapshots(bs);
return -1;
}
开发者ID:deepakar,项目名称:CS111-S13,代码行数:54,代码来源:qcow2-snapshot.c
示例4: vcard_emul_alloc_arrays
/*
* allocate the set of arrays for certs, cert_len, key
*/
static PRBool
vcard_emul_alloc_arrays(unsigned char ***certsp, int **cert_lenp,
VCardKey ***keysp, int cert_count)
{
*certsp = NULL;
*cert_lenp = NULL;
*keysp = NULL;
*certsp = (unsigned char **)qemu_malloc(sizeof(unsigned char *)*cert_count);
*cert_lenp = (int *)qemu_malloc(sizeof(int)*cert_count);
*keysp = (VCardKey **)qemu_malloc(sizeof(VCardKey *)*cert_count);
return PR_TRUE;
}
开发者ID:mithleshvrts,项目名称:qemu-kvm-rhel6,代码行数:15,代码来源:vcard_emul_nss.c
示例5: qemu_malloc
void *qemu_realloc(void *ptr, size_t size)
{
size_t old_size, copy;
void *new_ptr;
if (!ptr)
return qemu_malloc(size);
old_size = *(size_t *)((char *)ptr - 16);
copy = old_size < size ? old_size : size;
new_ptr = qemu_malloc(size);
memcpy(new_ptr, ptr, copy);
qemu_free(ptr);
return new_ptr;
}
开发者ID:mithleshvrts,项目名称:qemu-kvm-rhel6,代码行数:14,代码来源:mmap.c
示例6: cloop_open
static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size,max_compressed_block_size=1,i;
s->fd = open(filename, O_RDONLY | O_BINARY);
if (s->fd < 0)
return -errno;
bs->read_only = 1;
/* read header */
if(lseek(s->fd,128,SEEK_SET)<0) {
cloop_close:
close(s->fd);
return -1;
}
if(qemu_read_ok(s->fd,&s->block_size,4)<0)
goto cloop_close;
s->block_size=be32_to_cpu(s->block_size);
if(qemu_read_ok(s->fd,&s->n_blocks,4)<0)
goto cloop_close;
s->n_blocks=be32_to_cpu(s->n_blocks);
/* read offsets */
offsets_size=s->n_blocks*sizeof(uint64_t);
if(!(s->offsets=(uint64_t*)malloc(offsets_size)))
goto cloop_close;
if(read(s->fd,s->offsets,offsets_size)<offsets_size)
goto cloop_close;
for(i=0; i<s->n_blocks; i++) {
s->offsets[i]=be64_to_cpu(s->offsets[i]);
if(i>0) {
uint32_t size=s->offsets[i]-s->offsets[i-1];
if(size>max_compressed_block_size)
max_compressed_block_size=size;
}
}
/* initialize zlib engine */
s->compressed_block = qemu_malloc(max_compressed_block_size+1);
s->uncompressed_block = qemu_malloc(s->block_size);
if(inflateInit(&s->zstream) != Z_OK)
goto cloop_close;
s->current_block=s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks*s->sectors_per_block;
return 0;
}
开发者ID:junbo-hu,项目名称:xen-4.5.0,代码行数:49,代码来源:block-cloop.c
示例7: cloop_open
static int cloop_open(BlockDriverState *bs, int flags)
{
BDRVCloopState *s = bs->opaque;
uint32_t offsets_size,max_compressed_block_size=1,i;
bs->read_only = 1;
if (bdrv_pread(bs->file, 128, &s->block_size, 4) < 4) {
goto cloop_close;
}
s->block_size = be32_to_cpu(s->block_size);
if (bdrv_pread(bs->file, 128 + 4, &s->n_blocks, 4) < 4) {
goto cloop_close;
}
s->n_blocks = be32_to_cpu(s->n_blocks);
offsets_size = s->n_blocks * sizeof(uint64_t);
s->offsets = qemu_malloc(offsets_size);
if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
offsets_size) {
goto cloop_close;
}
for(i=0;i<s->n_blocks;i++) {
s->offsets[i]=be64_to_cpu(s->offsets[i]);
if(i>0) {
uint32_t size=s->offsets[i]-s->offsets[i-1];
if(size>max_compressed_block_size)
max_compressed_block_size=size;
}
}
s->compressed_block = qemu_malloc(max_compressed_block_size+1);
s->uncompressed_block = qemu_malloc(s->block_size);
if(inflateInit(&s->zstream) != Z_OK)
goto cloop_close;
s->current_block=s->n_blocks;
s->sectors_per_block = s->block_size/512;
bs->total_sectors = s->n_blocks*s->sectors_per_block;
return 0;
cloop_close:
return -1;
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:48,代码来源:cloop.c
示例8: parallels_open
static int parallels_open(BlockDriverState *bs, int flags)
{
BDRVParallelsState *s = bs->opaque;
int i;
struct parallels_header ph;
bs->read_only = 1;
if (bdrv_pread(bs->file, 0, &ph, sizeof(ph)) != sizeof(ph))
goto fail;
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
goto fail;
}
bs->total_sectors = le32_to_cpu(ph.nb_sectors);
s->tracks = le32_to_cpu(ph.tracks);
s->catalog_size = le32_to_cpu(ph.catalog_entries);
s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=
s->catalog_size * 4)
goto fail;
for (i = 0; i < s->catalog_size; i++)
le32_to_cpus(&s->catalog_bitmap[i]);
return 0;
fail:
if (s->catalog_bitmap)
qemu_free(s->catalog_bitmap);
return -1;
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:34,代码来源:parallels.c
示例9: do_freebsd_sysctl
/* XXX this needs to be emulated on non-FreeBSD hosts... */
static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong oldp,
abi_ulong oldlenp, abi_ulong newp, abi_ulong newlen)
{
abi_long ret;
void *hnamep, *holdp, *hnewp = NULL;
size_t holdlen;
abi_ulong oldlen = 0;
int32_t *snamep = qemu_malloc(sizeof(int32_t) * namelen), *p, *q, i;
uint32_t kind = 0;
if (oldlenp)
get_user_ual(oldlen, oldlenp);
if (!(hnamep = lock_user(VERIFY_READ, namep, namelen, 1)))
return -TARGET_EFAULT;
if (newp && !(hnewp = lock_user(VERIFY_READ, newp, newlen, 1)))
return -TARGET_EFAULT;
if (!(holdp = lock_user(VERIFY_WRITE, oldp, oldlen, 0)))
return -TARGET_EFAULT;
holdlen = oldlen;
for (p = hnamep, q = snamep, i = 0; i < namelen; p++, i++)
*q++ = tswap32(*p);
oidfmt(snamep, namelen, NULL, &kind);
/* XXX swap hnewp */
ret = get_errno(sysctl(snamep, namelen, holdp, &holdlen, hnewp, newlen));
if (!ret)
sysctl_oldcvt(holdp, holdlen, kind);
put_user_ual(holdlen, oldlenp);
unlock_user(hnamep, namep, 0);
unlock_user(holdp, oldp, holdlen);
if (hnewp)
unlock_user(hnewp, newp, 0);
qemu_free(snamep);
return ret;
}
开发者ID:AmesianX,项目名称:qemu-kvm,代码行数:35,代码来源:syscall.c
示例10: InsertSocketHandle
PSOCKET_ENTRY
InsertSocketHandle(
IN ULONG ProcessId,
IN HANDLE SocketHandle
)
{
PSOCKET_ENTRY Entry;
if (!s_SocketListInitialized)
return NULL;
Entry = (PSOCKET_ENTRY)qemu_malloc(sizeof(SOCKET_ENTRY));
if(Entry)
{
//fprintf(stderr, "InsertSocketHandle(PID:%d; SocketHandle:%x)\n", ProcessId, SocketHandle);
memset(Entry, 0, sizeof(SOCKET_ENTRY));
Entry->SocketHandle = SocketHandle;
Entry->ProcessId = ProcessId;
Entry->protocol = IPPROTO_IP;
InsertHeadList(&s_SocketList, &Entry->ListEntry);
}
return Entry;
}
开发者ID:wmalik,项目名称:Qebek_Linux,代码行数:28,代码来源:qebek-nt-network-helper.c
示例11: unix_listen
/* compatibility wrapper */
int unix_listen(const char *str, char *ostr, int olen)
{
QemuOpts *opts;
char *path, *optstr;
int sock, len;
opts = qemu_opts_create(&dummy_opts, NULL, 0);
optstr = strchr(str, ',');
if (optstr) {
len = optstr - str;
if (len) {
path = qemu_malloc(len+1);
snprintf(path, len+1, "%.*s", len, str);
qemu_opt_set(opts, "path", path);
qemu_free(path);
}
} else {
qemu_opt_set(opts, "path", str);
}
sock = unix_listen_opts(opts);
if (sock != -1 && ostr)
snprintf(ostr, olen, "%s%s", qemu_opt_get(opts, "path"), optstr ? optstr : "");
qemu_opts_del(opts);
return sock;
}
开发者ID:16aug,项目名称:nvmeqemu,代码行数:29,代码来源:qemu-sockets.c
示例12: vnc_set_x509_credential
static int vnc_set_x509_credential(VncDisplay *vd,
const char *certdir,
const char *filename,
char **cred,
int ignoreMissing)
{
struct stat sb;
if (*cred) {
qemu_free(*cred);
*cred = NULL;
}
*cred = qemu_malloc(strlen(certdir) + strlen(filename) + 2);
strcpy(*cred, certdir);
strcat(*cred, "/");
strcat(*cred, filename);
VNC_DEBUG("Check %s\n", *cred);
if (stat(*cred, &sb) < 0) {
qemu_free(*cred);
*cred = NULL;
if (ignoreMissing && errno == ENOENT)
return 0;
return -1;
}
return 0;
}
开发者ID:Leecheolhee,项目名称:VSSIM,代码行数:30,代码来源:vnc-tls.c
示例13: qemu_iovec_init
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint)
{
qiov->iov = qemu_malloc(alloc_hint * sizeof(struct iovec));
qiov->niov = 0;
qiov->nalloc = alloc_hint;
qiov->size = 0;
}
开发者ID:dtatulea,项目名称:qemu,代码行数:7,代码来源:cutils.c
示例14: kvmppc_read_host_property
int kvmppc_read_host_property(const char *node_path, const char *prop,
void *val, size_t len)
{
char *path;
FILE *f;
int ret = 0;
int pathlen;
pathlen = snprintf(NULL, 0, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop)
+ 1;
path = qemu_malloc(pathlen);
snprintf(path, pathlen, "%s/%s/%s", PROC_DEVTREE_PATH, node_path, prop);
f = fopen(path, "rb");
if (f == NULL) {
ret = errno;
goto free;
}
len = fread(val, len, 1, f);
if (len != 1) {
ret = ferror(f);
goto close;
}
close:
fclose(f);
free:
free(path);
out:
return ret;
}
开发者ID:bulotus,项目名称:bulotus-qemu-at91sam9263ek,代码行数:33,代码来源:kvm_ppc.c
示例15: qemu_sglist_init
void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint)
{
qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry));
qsg->nsg = 0;
qsg->nalloc = alloc_hint;
qsg->size = 0;
}
开发者ID:0-14N,项目名称:NDroid,代码行数:7,代码来源:dma-helpers.c
示例16: InsertCsrssPortHandle
VOID
InsertCsrssPortHandle(
IN ULONG ProcessId,
IN HANDLE PortHandle,
IN ULONG VirtualOffset
)
{
PCSRSS_PORT_HANDLE_ENTRY Entry;
if (!s_PortDataInitialized)
return;
Entry = (PCSRSS_PORT_HANDLE_ENTRY)qemu_malloc(sizeof(CSRSS_PORT_HANDLE_ENTRY));
if (!Entry)
return;
//fprintf(stderr, "InsertCsrssPortHandle(PID:%xh; PortHandle:%xh; Offset:0x%08x)\n", ProcessId, PortHandle, VirtualOffset);
Entry->PortHandle = PortHandle;
Entry->ProcessId = ProcessId;
Entry->VirtualOffset = VirtualOffset;
InsertHeadList(&s_PortHandleList, &Entry->ListEntry);
}
开发者ID:wmalik,项目名称:Qebek_Linux,代码行数:25,代码来源:qebek-nt-console-helper.c
示例17: spapr_finalize_fdt
static void spapr_finalize_fdt(sPAPREnvironment *spapr,
target_phys_addr_t fdt_addr,
target_phys_addr_t rtas_addr,
target_phys_addr_t rtas_size)
{
int ret;
void *fdt;
fdt = qemu_malloc(FDT_MAX_SIZE);
/* open out the base tree into a temp buffer for the final tweaks */
_FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));
ret = spapr_populate_vdevice(spapr->vio_bus, fdt);
if (ret < 0) {
fprintf(stderr, "couldn't setup vio devices in fdt\n");
exit(1);
}
/* RTAS */
ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);
if (ret < 0) {
fprintf(stderr, "Couldn't set up RTAS device tree properties\n");
}
_FDT((fdt_pack(fdt)));
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
qemu_free(fdt);
}
开发者ID:awilliam,项目名称:qemu,代码行数:31,代码来源:spapr.c
示例18: qemu_malloc
struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd)
{
int r;
struct vhost_net *net = qemu_malloc(sizeof *net);
if (!backend) {
fprintf(stderr, "vhost-net requires backend to be setup\n");
goto fail;
}
r = vhost_net_get_fd(backend);
if (r < 0) {
goto fail;
}
net->vc = backend;
net->dev.backend_features = tap_has_vnet_hdr(backend) ? 0 :
(1 << VHOST_NET_F_VIRTIO_NET_HDR);
net->backend = r;
r = vhost_dev_init(&net->dev, devfd);
if (r < 0) {
goto fail;
}
if (~net->dev.features & net->dev.backend_features) {
fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",
(uint64_t)(~net->dev.features & net->dev.backend_features));
vhost_dev_cleanup(&net->dev);
goto fail;
}
/* Set sane init value. Override when guest acks. */
vhost_net_ack_features(net, 0);
return net;
fail:
qemu_free(net);
return NULL;
}
开发者ID:EgoIncarnate,项目名称:qemu-rr,代码行数:35,代码来源:vhost_net.c
示例19: fw_cfg_add_i64
int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
{
uint64_t *copy;
copy = qemu_malloc(sizeof(value));
*copy = cpu_to_le64(value);
return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
}
开发者ID:Ringdingcoder,项目名称:qemu,代码行数:8,代码来源:fw_cfg.c
示例20: qemu_malloc
static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
{
VirtIOBlockReq *req = qemu_malloc(sizeof(*req));
req->dev = s;
req->qiov.size = 0;
req->next = NULL;
return req;
}
开发者ID:dtatulea,项目名称:qemu,代码行数:8,代码来源:virtio-blk.c
注:本文中的qemu_malloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论