473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

over loading new and delete question

hi all
i want overload new and delete . so i can use my buff

my os windows 2k sp4
compiler vs 2003

code:

#include "ace/Task.h"
#include "ace/OS_NS_unistd.h"

#include <iostream>
using namespace std;

#define table_len 1024*10240

class p_table;
class process {
public:
process() { /*cout<<"construct"<<'\n'; */}
~process() { /*cout<<"destruct"<<'\n'; */}
void * operator new(size_t s)
{
p_table *p =p_table::get_table();
// errow p_table *p =p_table::get_table();
// i think it is right can you show me the reason?
// thank you
return p->pop();
}

void operator delete (void *p)
{
p_table *p =p_table::get_table();
//errow
//
p->push((process * )p);
}

private:
double mm;
long xxx;
int age;
double aaa;
float ssss;

};

class p_table
{

public:
static p_table* get_table()
{
static p_table tmp;
return &tmp;
}
process * pop()
{

process * newnod = NULL;
mutex_.acquire();
if ( m_size)
{
newnod = tab[m_size-1];
tab[m_size-1] = NULL;
m_size--;
}
else
newnod = ( process *)::operator new (sizeof (process));
mutex_.release();

return newnod;

}

bool push (process * p)
{
mutex_.acquire();
if ( m_size < table_len)
{
tab[m_size] = p;
m_size++;
}
else
::operator delete( p);
mutex_.release();
return true;
}

private:
ACE_Thread_Mutex mutex_;
process * tab[table_len];
int m_size;

protected:

p_table():m_size(0)
{
mutex_.acquire();
for (int i = 0; i < table_len ; i++)
tab[i] = NULL;
mutex_.release();
}
};

there are some bug . can you fix it? thanks

papaka

May 28 '06 #1
3 1374
papamms wrote:
there are some bug . can you fix it? thanks


You'll have to be more specific about the kind of help you want --
nobody's going to waste hours trying to determine what bugs you're
experiencing simply because you didn't take the time to describe them.

Furthermore, you need to post complete, compilable, minimal code which
demonstrates the problem you're having.

This newsgroup is not for free debugging services. Read the FAQ,
please, before posting again.

Luke

May 28 '06 #2
hi luck
i just mean
p_table *p =p_table::get_table();
// errow p_table *p =p_table::get_table();
// i think it is right can you show me the reason?
// thank you

p_table *p =p_table::get_table();
//errow
//

there are two bugs. it can not been compile.

May 29 '06 #3
papamms wrote:
hi luck
i just mean
p_table *p =p_table::get_table();
// errow p_table *p =p_table::get_table();
// i think it is right can you show me the reason?
// thank you

p_table *p =p_table::get_table();
//errow
//

there are two bugs. it can not been compile.


I say thee again, READ THE FAQ.

Luke

May 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand K Rayudu | last post by:
Hi all, I have defined q python class and want to know if i can over load '=' operator. Here is my scenario Def myClass: __init__(self,a): # a is C Object c_obj = a
3
by: lreames | last post by:
I am running SQL 2000 SP2 on a Win 2000 box. I attempted to restore a dB a couple of times and the restore failed, but the dB appears in EM twice, once with Loading and the other with Read-Only. ...
0
by: Hayato Iriumi | last post by:
Hello, folks. I'm having a problem with loading Web project. Here is the situation. Windows Server 2003 VS .NET 2003 Source Safe 6.0d My IIS has a three sites.
5
by: matthewtec | last post by:
This may be something that is painfully easy and I'm just missing, or it could be something that I should learn a bit more in order to do. But, if I have a simple windows form application, with...
2
by: KN | last post by:
Hello, Is it possible to provide the .aspx mark up to the buildmanager from a resource for compilation and load it whithout having the .aspx file in the virtual folder? Since, the registered...
2
by: technocrat | last post by:
I am trying to load from a cursor which selects 124 million records...but while loading it completes the build phase and it stuck ...I think...at the delete phase(which in turn looks like doing the...
1
by: David Belohrad | last post by:
Dear All, could someone give a hint? I'd like to share the resources as follows: A shared class which works as counter of number of shared resources: class Shared { public: Q_PCBShared()...
6
by: Nebulism | last post by:
I have been attempting to utilize a draw command script that loads a canvas, and through certain mouse events, draws rectangles. The original code is from...
1
Banfa
by: Banfa | last post by:
So the basic sequenced C++ containers are vector - holds data in a contiguous memory block that has the same memory footprint as a classical array. Expensive to insert or delete at the front or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.