malloc 랩핑 함수에 대하여..

upersbird의 이미지

#define _ALLOC(size) alloc_body(size, __func__)
void *alloc_body(size_t size, const char *log)
{
    void *ret;
    ret = malloc(size);
    if(!ret)
    {
        printf("memory allocation error!\n");
        return NULL;
    }
    return ret;
}
...
char *buf = NULL;
buf = _ALLOC(100);
...

이때, 컴파일을 하면

warning: cast to pointer from integer of different size

위와 같은 경고가 뜨는데, 자료형을 바꾸고 캐스팅을 다르게 해봐도 안되네요..

이거 참 질문도 허허;;

upersbird의 이미지

buf = malloc(100); 으로 변경하면 또 경고가 없네요 허허...

라스코니의 이미지

size_t 대신에 int 를 쓰면 될까요?