]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/testutil/apps_shims.c
test: rename apps_mem.c to be apps_shims.c in anticipation of additonal functions
[thirdparty/openssl.git] / test / testutil / apps_shims.c
CommitLineData
ce506d27 1/*
f5afac4b 2 * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
ce506d27
RL
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
f31bbeff 10#include <stdlib.h>
ce506d27 11#include "apps.h"
f31bbeff 12#include "../testutil.h"
ce506d27
RL
13
14/* shim that avoids sucking in too much from apps/apps.c */
15
b1c908f4 16void *app_malloc(size_t sz, const char *what)
ce506d27 17{
f31bbeff 18 void *vp;
ce506d27 19
f31bbeff
P
20 /*
21 * This isn't ideal but it is what the app's app_malloc() does on failure.
22 * Instead of exiting with a failure, abort() is called which makes sure
23 * that there will be a good stack trace for debugging purposes.
24 */
25 if (!TEST_ptr(vp = OPENSSL_malloc(sz))) {
26 TEST_info("Could not allocate %zu bytes for %s\n", sz, what);
27 abort();
28 }
ce506d27
RL
29 return vp;
30}