URI: 
       tarrays.[ch]: check memory allocation and exit on fail, add some helper functions - cngf-pf - continuum model for granular flows with pore-pressure dynamics (renamed from 1d_fd_simple_shear)
  HTML git clone git://src.adamsgaard.dk/cngf-pf
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 1e6942b9f9ad1018f0ed75947ebe69cda5b047f5
   DIR parent ee23eff931ba11a8789ed2d47b9b42802da4fa7d
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Thu, 18 Mar 2021 14:41:37 +0100
       
       arrays.[ch]: check memory allocation and exit on fail, add some helper functions
       
       Diffstat:
         M arrays.c                            |      10 ++++++++--
       
       1 file changed, 8 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/arrays.c b/arrays.c
       t@@ -106,7 +106,7 @@ zeros(const int n)
                double *x;
        
                check_magnitude(__func__, 1, n);
       -        if (!(x = malloc(n * sizeof(double))))
       +        if (!(x = calloc(n, sizeof(double))))
                        err(1, "%s: x calloc", __func__);
                for (i = 0; i < n; ++i)
                        x[i] = 0.0;
       t@@ -150,8 +150,14 @@ initval(const double value, const int n)
        double *
        empty(const int n)
        {
       +        double *out;
       +
                check_magnitude(__func__, 1, n);
       -        return malloc(n * sizeof(double));
       +
       +        if (!(out = malloc(n * sizeof(double))))
       +                err(1, "%s: calloc", __func__);
       +
       +        return out;
        }
        
        /* Return largest value in array `a` with size `n` */