未验证 提交 a3ef623d 编写于 作者: N Ning Yu 提交者: GitHub

ic-proxy: type checking in ic_proxy_new()

A typical mistake on allocating typed memory is as below:

    int64 *ptr = malloc(sizeof(int32));

To prevent this, now we make ic_proxy_new() a typed allocator, it always
return a pointer of the specified type, for example:

    int64 *p1 = ic_proxy_new(int64); /* good */
    int64 *p2 = ic_proxy_new(int32); /* bad, gcc will raise a warning */
Reviewed-by: NHubert Zhang <hzhang@pivotal.io>
上级 81f4406f
......@@ -31,7 +31,7 @@
#define ic_proxy_alloc(size) palloc(size)
#define ic_proxy_free(ptr) pfree(ptr)
#define ic_proxy_new(type) ic_proxy_alloc(sizeof(type))
#define ic_proxy_new(type) ((type *) ic_proxy_alloc(sizeof(type)))
#define ic_proxy_log(elevel, msg...) do { \
if (elevel >= IC_PROXY_LOG_LEVEL) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册