/* Copyright (C) 2015-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4mema.ctr */ /** @file dk4mema.c The dk4mema module. */ #line 72 "dk4mema.ctr" #include "dk4conf.h" #include "dk4mema.h" #include "dk4mem.h" #include "dk4maodd.h" #include "dk4const.h" #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif void * dk4mem_calloc_app(size_t elsize, size_t nelem, dk4_app_t *app) { dkChar elsb[64]; dkChar nelb[64]; void *back = NULL; dk4_er_t er; int res; #if DK4_USE_ASSERT assert(0 < elsize); assert(0 < nelem); #endif dk4error_init(&er); back = dk4mem_calloc(elsize, nelem, &er); if (NULL == back) { res = dk4ma_write_decimal_unsigned( elsb, DK4_SIZEOF(elsb,dkChar), (dk4_um_t)elsize, 0, NULL ); if (0 != res) { res = dk4ma_write_decimal_unsigned( nelb, DK4_SIZEOF(nelb,dkChar), (dk4_um_t)nelem, 0, NULL ); } switch (er.ec) { case DK4_E_MATH_OVERFLOW: { /* ERROR: Numeric overflow in size calculation */ if (0 != res) { dk4app_log_base5(app,DK4_LL_ERROR,83,84,85,nelb,elsb); } else { dk4app_log_base1(app, DK4_LL_ERROR, 82); } } break; case DK4_E_INVALID_ARGUMENTS: { /* ERROR: Invalid sizes */ if (0 != res) { dk4app_log_base5(app,DK4_LL_ERROR,87,88,89,nelb,elsb); } else { dk4app_log_base1(app, DK4_LL_ERROR, 86); } } break; default: { /* ERROR: Not enough memory */ if (0 != res) { dk4app_log_base5(app,DK4_LL_ERROR,91,92,93,nelb,elsb); } else { dk4app_log_base1(app, DK4_LL_ERROR, 90); } } break; } } return back; }