how to do ?

P

Priya Mishra

Hi Readers !!!!

I have been given the work that I have to remove all the runtime
library's internal memory sub-allocation with the local_malloc
function which is going to do all the static memory allocation.

I have the library source code in which I have to remove
all the calloc and malloc,

please help me from where to start I am newbe.

Any pointer to this will be highly helpful to me

Thanks and Regards
Priya
 
W

Walter Roberson

I have been given the work that I have to remove all the runtime
library's internal memory sub-allocation with the local_malloc
function which is going to do all the static memory allocation.
I have the library source code in which I have to remove
all the calloc and malloc,
please help me from where to start I am newbe.

Is there a possible mechanical translation between the existing calls
and the new calls? For example, "use the second parameter first,
followed by the constant 65535, followed by the first parameter" ? If
such a mechanical translation is possible then depending on the
complexity of the call sequence (e.g., embedded comments, split over
several lines) I would use an editor with regular expression
matching, or 'sed', or 'awk', or 'perl' to do the transformation.

This is a C newsgroup, so of course you could also write a C program
to do the mechanical transformation, but tools such as perl have
a lot of built-in text matching and manipulation features that would
tend to make it easier to use those tools than to write the corresponding
C program.


If no mechanical translation is possible, then you haven't really
given us enough information to go on for us to be of assistance.
 
M

Mark

Priya Mishra said:
Hi Readers !!!!
I have been given the work that I have to remove all the runtime
I'm guessing you meant 'replace'
library's internal memory sub-allocation with the local_malloc
function which is going to do all the static memory allocation.
I'm guessing you meant 'dynamic'
I have the library source code in which I have to remove
all the calloc and malloc,
please help me from where to start I am newbe.
Any pointer to this will be highly helpful to me
Thanks and Regards
Priya

<ot>
Personal question, you don't have to answer but I have to ask to satisfy my
own curiosity.
Do you work for a company which provides outsourcing services for US
companies?
I'm wondering if they pull people in from off of the street and assign them
to projects they
have no business working on... maybe that's how they provide their services
so cheap!
(Yes, I am disgruntled, I was 'indirectly' affected by a major company
which decided
to outsource... I lost many colleagues and a few mentors as a result.)
</ot>

As for the problem at hand:
If you really want to start by removing all of the calls:
grep -v calloc < oldsrc.c | grep -v malloc > newsrc.c
That will do the trick :) :) ;-) :) :)

Mark
 
C

CBFalconer

Priya said:
I have been given the work that I have to remove all the runtime
library's internal memory sub-allocation with the local_malloc
function which is going to do all the static memory allocation.

I have the library source code in which I have to remove
all the calloc and malloc,

please help me from where to start I am newbe.

Any pointer to this will be highly helpful to me

This has got to be a troll.
 
G

Gregory Pietsch

Priya said:
Hi Readers !!!!

I have been given the work that I have to remove all the runtime
library's internal memory sub-allocation with the local_malloc
function which is going to do all the static memory allocation.

And why, pray tell, do you want to do this? Are you trying to write a
really funky bounds checker?
I have the library source code in which I have to remove
all the calloc and malloc,

In C++ it's fairly trivial to replace all malloc() with the new
operator. But this is comp.lang.c, not comp.lang.c++. You will have
to write your constructor functions explicitly.
please help me from where to start I am newbe.

In other words, this was a homework assignment?
Any pointer to this will be highly helpful to me

If you need dynamic array code or dynamic string code or dynamic array
of dynamic string code, just download FreeDOS Edlin 2.5 (available on
ibiblio or alt.sources) and marvel.
Thanks and Regards
Priya

Gregory Pietsch
 
S

Sensei

Hi Readers !!!!

I have been given the work that I have to remove all the runtime
library's internal memory sub-allocation with the local_malloc
function which is going to do all the static memory allocation.

I have the library source code in which I have to remove
all the calloc and malloc,

please help me from where to start I am newbe.

Any pointer to this will be highly helpful to me

You mean REPLACE all the occurrencies of malloc() with the NEW FUNCTION
called local_malloc()?

If so, in first place, it has nothing to do with C, but better with
string manipulation.

If all mallocs are just ONE PER LINE, then:

cat FILENAME | sed s/malloc/local_malloc/ > FILENAME_NEW

so, for all the files in a BASH SHELL or SH or ZSH:


for i in `find . -name "*.c"`; do cat $i | sed s/malloc/local_malloc/ >
$i.NEW; done


Or, try using a good editor with a search & replace inside files feature
..
 
N

Nitin

Mark said:
I'm guessing you meant 'replace'

I'm guessing you meant 'dynamic'


<ot>
Personal question, you don't have to answer but I have to ask to satisfy my
own curiosity.
Do you work for a company which provides outsourcing services for US
companies?
I'm wondering if they pull people in from off of the street and assign them
to projects they
have no business working on... maybe that's how they provide their services
so cheap!
(Yes, I am disgruntled, I was 'indirectly' affected by a major company
which decided
to outsource... I lost many colleagues and a few mentors as a result.)
</ot>

As for the problem at hand:
If you really want to start by removing all of the calls:
grep -v calloc < oldsrc.c | grep -v malloc > newsrc.c
That will do the trick :) :) ;-) :) :)

Mark

<OT>

First off, cheap need not necessarily mean inferior quality ! A case in
point is MS Windows vs. GNU/Linux !
Every now and then I see "hate"-posts like this. People loosing out
their jobs due to out-sourcing venting their anger in public fora like
c.l.c . You should learn to come to term with realities of a
globalised world.If out-sourcing services would have de-graded the
quality of services, then this would have never worked out in the first
place !

</OT>
 
K

Kenny McCormack

Nitin said:
<OT>

First off, cheap need not necessarily mean inferior quality ! A case in
point is MS Windows vs. GNU/Linux !
Every now and then I see "hate"-posts like this. People loosing out
their jobs due to out-sourcing venting their anger in public fora like
c.l.c . You should learn to come to term with realities of a
globalised world.If out-sourcing services would have de-graded the
quality of services, then this would have never worked out in the first
place !

</OT>

I take it, that's a "yes", then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,166
Messages
2,570,907
Members
47,448
Latest member
DeanaQ4445

Latest Threads

Top