OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
analyse_memory.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "analyse_memory.h"

Go to the source code of this file.

Functions

void * analyse_malloc (size_t size)
void * analyse_realloc (void *block, size_t size)
void * analyse_calloc (size_t nitems, size_t size)
void analyse_free (void *block)
void * analyse_recalloc (void *block, size_t nitems, size_t size)

Function Documentation

◆ analyse_calloc()

void * analyse_calloc ( size_t nitems,
size_t size )

Definition at line 57 of file analyse_memory.c.

58{
59 return calloc(nitems, size);
60}

◆ analyse_free()

void analyse_free ( void * block)

Definition at line 63 of file analyse_memory.c.

64{
65 if( block == NULL)
66 return;
67
68 free(block);
69
70}

◆ analyse_malloc()

void * analyse_malloc ( size_t size)

Definition at line 39 of file analyse_memory.c.

40{
41 if (size == 0)
42 return NULL;
43
44 return malloc(size);
45}

◆ analyse_realloc()

void * analyse_realloc ( void * block,
size_t size )

Definition at line 48 of file analyse_memory.c.

49{
50 if(block == NULL)
51 return analyse_malloc(size);
52 else
53 return realloc(block, size);
54}
void * analyse_malloc(size_t size)

◆ analyse_recalloc()

void * analyse_recalloc ( void * block,
size_t nitems,
size_t size )

Definition at line 71 of file analyse_memory.c.

72{
73 void *array ;
74
75 array = (void *)calloc(nitems, size) ;
76
77 if (array == NULL)
78 {
79 printf("Not enough memory left...\n") ;
80 return (array) ;
81 }
82
83 if (sizeof(block) <= sizeof(array))
84 {
85 array = memcpy(array, block, sizeof(block)) ;
86 }
87 else
88 {
89 array = memcpy(array, block, sizeof(array)) ;
90
91 }
92
93 free(block) ;
94
95 return (array) ;
96}