[x265] [PATCH] CHECKED_MALLOC : Added X265_log if Malloc failed Report the ERROR Log message
Steve Borho
steve at borho.org
Fri Sep 20 08:38:15 CEST 2013
On Fri, Sep 20, 2013 at 1:21 AM, Gopu Govindaswamy <
gopu at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> # Date 1379658081 -19800
> # Node ID 8831d644fa9bb931ef52db7dd8c90e08786b36fe
> # Parent 99a33fc4356a7daf3b09cd5e99687fa00e23051d
> CHECKED_MALLOC : Added X265_log if Malloc failed Report the ERROR Log
> message
>
better as:
common: add CHECKED_MALLOC macro that logs malloc failures and jumps to
fail label
>
> diff -r 99a33fc4356a -r 8831d644fa9b source/common/common.cpp
> --- a/source/common/common.cpp Fri Sep 20 11:28:56 2013 +0530
> +++ b/source/common/common.cpp Fri Sep 20 11:51:21 2013 +0530
> @@ -86,7 +86,7 @@
>
> void x265_log(x265_param_t *param, int level, const char *fmt, ...)
> {
> - if (level > param->logLevel)
> + if ( param && level > param->logLevel)
>
extra white-space
> return;
> const char *log_level;
> switch (level)
> diff -r 99a33fc4356a -r 8831d644fa9b source/common/common.h
> --- a/source/common/common.h Fri Sep 20 11:28:56 2013 +0530
> +++ b/source/common/common.h Fri Sep 20 11:51:21 2013 +0530
> @@ -99,8 +99,11 @@
> #define CHECKED_MALLOC(var, type, count )\
> {\
> var = (type *)X265_MALLOC(type, sizeof(type) * (count));\
> - if( !var )\
> + if (!var)\
> + {\
> + x265_log(NULL, X265_LOG_ERROR, "malloc of size %d failed\n",
> sizeof(type) * (count));\
> goto fail;\
> + }\
> }
>
looks ok in general, but these two patches should be folded into one
>
> #define ENABLE_CYCLE_COUNTERS 0
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130920/c815a36e/attachment-0001.html>
More information about the x265-devel
mailing list