malloc

    2热度

    1回答

    我不能在线程内emalloc内存任意数量的内存,而不会触发https://github.com/php/php-src/blob/master/Zend/zend_alloc.c#L2409上的段错误。 只有在PHP(ZTS)的线程安全版本上运行时才会出现段错误(讽刺)。 当在普通的NTS版本上运行时,一切正常。 下面是一些可用于重现问题的代码(我使用php-cpp简化了扩展的创建)。 void*

    4热度

    6回答

    这里是我使用的代码: #include <stdio.h> #include <stdlib.h> int main() { int *arr; int sz = 100000; arr = (int *)malloc(sz * sizeof(int)); int i; for (i = 0; i < sz; ++i) { if

    2热度

    4回答

    在以下示例中,函数func()返回本地指针变量的地址为main()函数。它在GCC中工作正常。因此,它是明确的行为? #include <stdio.h> #include <stdlib.h> int *func(void); int *func(void) { int *p; p = malloc(sizeof *p); *p = 10; r

    -5热度

    1回答

    删除此话题,因为人们只是在UB停止会发生什么...

    -5热度

    1回答

    该程序应该创建一个结构数组,其中包含代码开始处的硬编码名称和年龄数组的名称和年龄值。 我一直被要求在主函数中声明数组,然后在插入函数中为它分配内存。程序编译罚款和我应该得​​到的输出是: 名称:西蒙 年龄:22 名称:苏丝 年龄:24 名称:阿尔弗雷德 年龄:106 姓名:芯片 年龄:6 等等,等等 但是输出我得到的是这样的: 名称:西蒙 年龄:22 名称:(空) 年龄:33 名称:苏丝 年龄:2

    -1热度

    1回答

    我使用polybench内核。在polybench.c中,代码的行数如下: int ret = posix_memalign (&new, 32, num); 这行代码会导致lli解释器出现问题。我试图使用malloc代替,但我有同样的错误 LLVM ERROR: Tried to execute an unknown external function: posix_memalign 是

    18热度

    1回答

    存在几种排列版本古老的malloc()的,例如: #include <stdlib.h> int posix_memalign(void **memptr, size_t alignment, size_t size); void *aligned_alloc(size_t alignment, size_t size); #include <malloc.h> void *memali

    0热度

    1回答

    在x86上,它可能无法在工作线程上初始化QImage。 (在x64中很少) 当在CPU的核心数量上执行并行处理时,可能性会增加。 这不仅是通过读取图像文件,而且通过指定它的大小初始化一个普通的QImage,或简单地通过调用QImage :: copy()。 这是避免它的代码。当然,这并不完美。 请告诉我一个更好的方法。 QImage createImageAsync(QString path)

    -1热度

    2回答

    我已经通读了大量的帖子,给出了可以从函数返回int类型数组的方法。我试图按照使用malloc()函数动态分配函数内部的方法。 在示例代码中,我使用的函数foo计算的数组中的峰值大于指定值。 #include <stdio.h> #include <stdlib.h> #include <string.h> /* function declaration */ int *foo(int a

    2热度

    3回答

    malloc函数声明: void *malloc(size_t size); 这里,malloc返回void指针。所以,A void函数什么也没有返回,然后 为什么我们将malloc(函数调用)赋值给指针? 例如: int *ptr; ptr = malloc(10 * sizeof (*ptr)); ^^^ 是什么返回值从malloc()持有???