[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] adding wrapper functions for new and delete operators

From: Bradley Jarvis
Subject: [avr-libc-dev] adding wrapper functions for new and delete operators
Date: Sat, 05 Feb 2011 17:47:04 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20110114 Lightning/1.0b2 Thunderbird/3.1.7

I use avr-gcc for c++ code (have so for years) and wanted to use new and
delete, particularly for libraries that I have written for and used in
an x86 environment which I didn't want to have to convert. So I wrote
the following wrapper functions, please feel free to add it to avr-libc

To go into a header file (not sure what the standard c++ header file new
and delete function would normally exist in, that that is where the
declarations would reside):

void *operator new(size_t);
void *operator new[](size_t);
void operator delete(void *);
void operator delete[](void *);

To go into the source file:

void *operator new(size_t s)
    return malloc(s);
void *operator new[](size_t s)
    return malloc(s);
void operator delete(void *m)
void operator delete[](void *m)

I have used these functions for years to get new and delete
functionality into my avr-gcc code.

BTW get job on the gcc avr support, it's a fantastic product. The only
other thing I would like to use that is not supported are exceptions, it
would make some software easier.

Thanks Brad

reply via email to

[Prev in Thread] Current Thread [Next in Thread]