2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/malloc.h
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_MALLOC_H
|
|
|
|
#define __INCLUDE_MALLOC_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-08-19 22:13:36 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-06-27 03:57:56 +08:00
|
|
|
/* For Linux and MacOS compatibility */
|
|
|
|
|
|
|
|
#define malloc_usable_size malloc_size
|
|
|
|
|
2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct mallinfo
|
|
|
|
{
|
|
|
|
int arena; /* This is the total size of memory allocated
|
|
|
|
* for use by malloc in bytes. */
|
|
|
|
int ordblks; /* This is the number of free (not in use) chunks */
|
2021-04-28 11:05:20 +08:00
|
|
|
int aordblks; /* This is the number of allocated (in use) chunks */
|
2020-06-15 10:38:55 +08:00
|
|
|
int mxordblk; /* Size of the largest free (not in use) chunk */
|
|
|
|
int uordblks; /* This is the total size of memory occupied by
|
|
|
|
* chunks handed out by malloc. */
|
|
|
|
int fordblks; /* This is the total size of memory occupied
|
|
|
|
* by free (not in use) chunks. */
|
|
|
|
};
|
|
|
|
|
2022-07-04 15:41:06 +08:00
|
|
|
#if CONFIG_MM_BACKTRACE >= 0
|
2022-01-22 20:21:51 +08:00
|
|
|
struct mallinfo_task
|
|
|
|
{
|
|
|
|
pid_t pid; /* The pid of task */
|
|
|
|
int aordblks; /* This is the number of allocated (in use) chunks for task */
|
|
|
|
int uordblks; /* This is the total size of memory occupied for task */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2020-06-15 10:38:55 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct mallinfo mallinfo(void);
|
2021-06-27 03:57:56 +08:00
|
|
|
size_t malloc_size(FAR void *ptr);
|
2022-07-04 15:41:06 +08:00
|
|
|
#if CONFIG_MM_BACKTRACE >= 0
|
2022-01-22 20:21:51 +08:00
|
|
|
struct mallinfo_task mallinfo_task(pid_t pid);
|
|
|
|
#endif
|
2020-06-15 10:38:55 +08:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __INCLUDE_MALLOC_H */
|