My Project
Macros | Functions
omalloc.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "omalloc.h"

Go to the source code of this file.

Macros

#define OMALLOC_C
 
#define OM_MARK_AS_STATIC(addr)   do {} while (0)
 

Functions

void * malloc (size_t size)
 
void freeSize (void *addr, size_t size)
 
void * reallocSize (void *old_addr, size_t old_size, size_t new_size)
 

Macro Definition Documentation

◆ OM_MARK_AS_STATIC

#define OM_MARK_AS_STATIC (   addr)    do {} while (0)

Definition at line 20 of file omalloc.c.

◆ OMALLOC_C

#define OMALLOC_C

Definition at line 13 of file omalloc.c.

Function Documentation

◆ freeSize()

void freeSize ( void *  addr,
size_t  size 
)

Definition at line 95 of file omalloc.c.

96 {
97  if (addr) omFreeSize(addr, size);
98 }
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260

◆ malloc()

void* malloc ( size_t  size)

Definition at line 85 of file omalloc.c.

86 {
87  void* addr;
88  if (size == 0) size = 1;
89 
90  omTypeAllocAligned(void*, addr, size);
91  OM_MARK_AS_STATIC(addr);
92  return addr;
93 }
#define omTypeAllocAligned
Definition: omAllocDecl.h:271
#define OM_MARK_AS_STATIC(addr)
Definition: omalloc.c:20

◆ reallocSize()

void* reallocSize ( void *  old_addr,
size_t  old_size,
size_t  new_size 
)

Definition at line 100 of file omalloc.c.

101 {
102  if (old_addr && new_size)
103  {
104  void* new_addr;
105  omTypeReallocAlignedSize(old_addr, old_size, void*, new_addr, new_size);
106  OM_MARK_AS_STATIC(new_addr);
107  return new_addr;
108  }
109  else
110  {
111  freeSize(old_addr, old_size);
112  return malloc(new_size);
113  }
114 }
#define omTypeReallocAlignedSize
Definition: omAllocDecl.h:276
void * malloc(size_t size)
Definition: omalloc.c:85
void freeSize(void *addr, size_t size)
Definition: omalloc.c:95