ssh

Dependents:   OS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers memory.h Source File

memory.h

00001 /* memory.h
00002  *
00003  * Copyright (C) 2014-2016 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSH.
00006  *
00007  * wolfSSH is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSH is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with wolfSSH.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 
00022 /*
00023  * The memory module contains the interface to the custom memory handling hooks.
00024  */
00025 
00026 
00027 #pragma once
00028 
00029 #include <wolfssh/settings.h>
00030 #include <stdlib.h>
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 
00037 typedef void *(*wolfSSH_Malloc_cb)(size_t size);
00038 typedef void (*wolfSSH_Free_cb)(void *ptr);
00039 typedef void *(*wolfSSH_Realloc_cb)(void *ptr, size_t size);
00040 
00041 
00042 /* Public set function */
00043 WOLFSSH_API int wolfSSH_SetAllocators(wolfSSH_Malloc_cb  malloc_function,
00044                                       wolfSSH_Free_cb    free_function,
00045                                       wolfSSH_Realloc_cb realloc_function);
00046 
00047 /* Public in case user app wants to use WMALLOC/WFREE */
00048 WOLFSSH_API void* wolfSSH_Malloc(size_t size);
00049 WOLFSSH_API void  wolfSSH_Free(void *ptr);
00050 WOLFSSH_API void* wolfSSH_Realloc(void *ptr, size_t size);
00051 
00052 
00053 #ifdef __cplusplus
00054 }
00055 #endif
00056