@@ -594,24 +594,33 @@ GpuElemwise *GpuElemwise_new(gpucontext *ctx,
594594 int ret ;
595595
596596 res = calloc (1 , sizeof (* res ));
597- if (res == NULL ) return NULL ;
597+ if (res == NULL ) {
598+ error_sys (ctx -> err , "calloc" );
599+ return NULL ;
600+ }
598601
599602 res -> flags = flags ;
600603 res -> nd = 8 ;
601604 res -> n = n ;
602605
603606 res -> expr = strdup (expr );
604- if (res -> expr == NULL )
607+ if (res -> expr == NULL ) {
608+ error_sys (ctx -> err , "strdup" );
605609 goto fail ;
610+ }
606611 if (preamble != NULL ) {
607612 res -> preamble = strdup (preamble );
608- if (res -> preamble == NULL )
613+ if (res -> preamble == NULL ) {
614+ error_sys (ctx -> err , "strdup" );
609615 goto fail ;
616+ }
610617 }
611618
612619 res -> args = copy_args (n , args );
613- if (res -> args == NULL )
620+ if (res -> args == NULL ) {
621+ error_sys (ctx -> err , "copy_args" );
614622 goto fail ;
623+ }
615624
616625 /* Count the arrays in the arguements */
617626 res -> narray = 0 ;
@@ -620,18 +629,26 @@ GpuElemwise *GpuElemwise_new(gpucontext *ctx,
620629
621630 while (res -> nd < nd ) res -> nd *= 2 ;
622631 res -> dims = calloc (res -> nd , sizeof (size_t ));
623- if (res -> dims == NULL )
632+ if (res -> dims == NULL ) {
633+ error_sys (ctx -> err , "calloc" );
624634 goto fail ;
635+ }
625636 res -> strides = strides_array (res -> narray , res -> nd );
626- if (res -> strides == NULL )
637+ if (res -> strides == NULL ) {
638+ error_sys (ctx -> err , "strides_array" );
627639 goto fail ;
640+ }
628641 res -> k_basic = calloc (res -> nd , sizeof (GpuKernel ));
629- if (res -> k_basic == NULL )
642+ if (res -> k_basic == NULL ) {
643+ error_sys (ctx -> err , "calloc" );
630644 goto fail ;
645+ }
631646
632647 res -> k_basic_32 = calloc (res -> nd , sizeof (GpuKernel ));
633- if (res -> k_basic_32 == NULL )
648+ if (res -> k_basic_32 == NULL ) {
649+ error_sys (ctx -> err , "calloc" );
634650 goto fail ;
651+ }
635652
636653 ret = gen_elemwise_contig_kernel (& res -> k_contig , ctx ,
637654#ifdef DEBUG
0 commit comments