This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
- (void) rgbMatrix:(UIImage *)i toRGB:(uint32_t **)rgbArray{
    int m_width = i.size.width;
    int m_height = i.size.height;
    *rgbArray = (uint32_t *) malloc(m_width * m_height * sizeof(uint32_t));
}

uint32_t *rgbArray = NULL;
[self rgbMatrix:image toRGB:&rgbArray];


有人可以帮忙吗?这是行不通的。在Objective-c中使用malloc不支持这种方式吗?

最佳答案

您似乎正确地通过引用传递了指针。

唯一可能存在问题的区域是将rgbArray声明为null(我认为只写uint32_t * rgbArray;是不正确的)。另一个问题是释放内存

08-05 16:13