2019-03-03 17:27:10 +08:00
|
|
|
/*
|
2021-04-22 21:38:44 +08:00
|
|
|
* Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2019-03-03 17:27:10 +08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
2021-06-20 10:40:48 +08:00
|
|
|
#include <stdlib.h>
|
2019-03-03 17:27:10 +08:00
|
|
|
#include "apps.h"
|
2021-06-20 10:40:48 +08:00
|
|
|
#include "../testutil.h"
|
2019-03-03 17:27:10 +08:00
|
|
|
|
|
|
|
/* shim that avoids sucking in too much from apps/apps.c */
|
|
|
|
|
2021-03-06 19:19:18 +08:00
|
|
|
void *app_malloc(size_t sz, const char *what)
|
2019-03-03 17:27:10 +08:00
|
|
|
{
|
2021-06-20 10:40:48 +08:00
|
|
|
void *vp;
|
2019-03-03 17:27:10 +08:00
|
|
|
|
2021-06-20 10:40:48 +08:00
|
|
|
/*
|
|
|
|
* This isn't ideal but it is what the app's app_malloc() does on failure.
|
|
|
|
* Instead of exiting with a failure, abort() is called which makes sure
|
|
|
|
* that there will be a good stack trace for debugging purposes.
|
|
|
|
*/
|
|
|
|
if (!TEST_ptr(vp = OPENSSL_malloc(sz))) {
|
|
|
|
TEST_info("Could not allocate %zu bytes for %s\n", sz, what);
|
|
|
|
abort();
|
|
|
|
}
|
2019-03-03 17:27:10 +08:00
|
|
|
return vp;
|
|
|
|
}
|