巧舌如簧内存分配错误 [英] Glib memory allocation error

查看:147
本文介绍了巧舌如簧内存分配错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是库 libfprint 在Ubuntu次我试图通过我的java code调用一个函数。

I am using a library libfprint on ubuntu nd I am trying to call a function through my java code.

API_EXPORTED struct fp_img *fpi_img_new(size_t length)
{
    struct fp_img *img = g_malloc(sizeof(*img) + length);
    memset(img, 0, sizeof(*img));
    fp_dbg("length=%zd", length);
    img->length = length;
    return img;
}

我从我的java code传递整数值5此功能。当我尝试执行上面的功能我得到了以下错误:

I am passing integer value 5 from my java code to this function. When I try to execute above function I got following errors:

GLib-ERROR **: /build/buildd/glib2.0-2.30.0/./glib/gmem.c:170: failed to allocate 3077591024 bytes

我已经试过2个不同的Ubuntu的机器上同样code,但错误是一样的。我不知道为什么,它试图为24 + 5的长度分配这么多字节。

I have tried same code on 2 different ubuntu machine but the error remains the same. I dont know why it is trying to allocate so many bytes for 24+5 length.

可能有人建议我任何解决方案?

Could anyone suggest me any solution?

推荐答案

源code 明确规定:

/* structs that applications are not allowed to peek into */
(...)
struct fp_img;

所以,我不知道你为了编译,甚至有一些需要结构fp_img 的大小做了什么:你不应该是能够做到即,由于结构的声明是不透明的。

So, I'm not sure what you did in order to even compile something that needs the size of struct fp_img: you're not supposed to be able to do that, since the structure declaration is opaque.

这篇关于巧舌如簧内存分配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆