Skip to content

Commit

Permalink
libglue: add C++ new/delete operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Mar 25, 2013
1 parent ef45d06 commit af27064
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libglue/Makefile
Expand Up @@ -2,7 +2,7 @@ MISPDIR=..
include $(MISPDIR)/common.mak

CFLAGS+=-I$(YAFFSDIR)/direct -I$(YAFFSDIR) -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_DEFINES_TYPES -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES -I$(MISPDIR)/libglue/include
OBJECTS=yaffs.o asprintf.o file.o getenv.o
OBJECTS=yaffs.o asprintf.o file.o getenv.o cppmm.o

all: libglue.a

Expand All @@ -13,6 +13,9 @@ libglue.a: $(OBJECTS)
$(AR) clr libglue.a $(OBJECTS)
$(RANLIB) libglue.a

%.o: %.cpp
$(compilexx-dep)

%.o: %.c
$(compile-dep)

Expand Down
28 changes: 28 additions & 0 deletions libglue/cppmm.cpp
@@ -0,0 +1,28 @@
#include <stdlib.h>

void *operator new(unsigned int sz) throw ()
{
void *p;

if(sz == 0)
sz = 1;
p = (void *)malloc(sz);
if(!p)
abort();
return p;
}

void *operator new[](unsigned int sz) throw ()
{
return ::operator new(sz);
}

void operator delete(void* ptr) throw ()
{
free(ptr);
}

void operator delete[](void *ptr) throw ()
{
::operator delete(ptr);
}

0 comments on commit af27064

Please sign in to comment.