473,568 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementation of sizeof, malloc, new

Hi,

Where can I get the source code that has the implementation of the
below
C operators/functions:
malloc
sizeof
new
strcmp
strtok

etc.,

(any website points to the source code)

I am using Linux OS with GCC as my C compiler.

Thanks in advance,
Anil.

Nov 14 '05 #1
12 7578
On Thu, 20 Jan 2005 04:09:18 -0800, Anil wrote:
Hi,

Where can I get the source code that has the implementation of the
below
C operators/functions:
malloc
sizeof
new
strcmp
strtok
There is no "the source" for these things, every compiler/system library
could have its own version.
etc.,

(any website points to the source code)

I am using Linux OS with GCC as my C compiler.


Since you are talking about open source tools you should be able to find
the source, or a pointer to it, from wherever you got the tools. The
source may even already be on your system.

Lawrence

Nov 14 '05 #2
Anil wrote:
Hi,

Where can I get the source code that has the implementation of the
below
C operators/functions:
malloc
sizeof
new
strcmp
strtok

etc.,

(any website points to the source code)

I am using Linux OS with GCC as my C compiler.

Thanks in advance,
Anil.


If you are using a Linux system, as you say you are, the man command is
useful for finding out which files the source of a particular function
is in. In this case, since I know the files off the top of my head,
I'll save you the work:
malloc() - stdlib.h
sizeof() - this is actually an operator
new() [not an ANSI C function] - again, an operator
strcmp() - string.h
strtok() - string.h
These files will be found in your C include directory.

-dave

Nov 14 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

dave windsor wrote:
Anil wrote:
Hi,

Where can I get the source code that has the implementation of the
below
C operators/functions:
malloc
sizeof
new
strcmp
strtok

etc.,

(any website points to the source code)

I am using Linux OS with GCC as my C compiler.

Thanks in advance,
Anil.

If you are using a Linux system, as you say you are, the man command is
useful for finding out which files the source of a particular function
is in. In this case, since I know the files off the top of my head,
I'll save you the work:
malloc() - stdlib.h

Wrong - stdlib.h contains some definitional values, but not the /source code/
for the malloc function.
sizeof() - this is actually an operator True. To find out how it was implemented, the OP will have to read the source
code of his C compiler.
new() [not an ANSI C function] - again, an operator True. To find out how it was implemented, the OP will have to read the source
code of his C++ compiler.
strcmp() - string.h Wrong - stdlib.h contains some definitional values, but not the /source code/
for the strcmp function.
strtok() - string.h Wrong - stdlib.h contains some definitional values, but not the /source code/
for the strtok function.
These files will be found in your C include directory.


The files you named will be found there. However, the files the OP is looking
for are unlikely to be found in his C include directory.
- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFB79WwagV FX4UWr64RArsSAJ sFcO63VBb/MH3GH148ZH1iEsk SuQCfQZp5
Pt7EpzUuLD9eK2r URod2Ods=
=FErO
-----END PGP SIGNATURE-----
Nov 14 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew Pitcher wrote:
dave windsor wrote:
Anil wrote:
Hi,

Where can I get the source code that has the implementation of the
below
C operators/functions:
malloc
sizeof
new
strcmp
strtok

etc.,

(any website points to the source code)

I am using Linux OS with GCC as my C compiler.

Thanks in advance,
Anil.
If you are using a Linux system, as you say you are, the man command is
useful for finding out which files the source of a particular function
is in. In this case, since I know the files off the top of my head,
I'll save you the work:
malloc() - stdlib.h
Wrong - stdlib.h contains some definitional values, but not the /source code/
for the malloc function.

sizeof() - this is actually an operator
True. To find out how it was implemented, the OP will have to read the source
code of his C compiler.

new() [not an ANSI C function] - again, an operator
True. To find out how it was implemented, the OP will have to read the source
code of his C++ compiler.

strcmp() - string.h
Wrong - stdlib.h cut'n'past error: I meant to say "string.h"
contains some definitional values, but not the /source code/
for the strcmp function.

strtok() - string.h
Wrong - stdlib.h cut'n'past error: I meant to say "string.h"
contains some definitional values, but not the /source code/
for the strtok function.

These files will be found in your C include directory.

The files you named will be found there. However, the files the OP is looking
for are unlikely to be found in his C include directory.

- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFB79X3agV FX4UWr64RAoBnAJ 9Aeg55hojNNjPVI iN3Ugn26s6kcQCf TMWL
wsFUNOOhVEwXbBD FQna/+CQ=
=tFg3
-----END PGP SIGNATURE-----
Nov 14 '05 #5
Lew Pitcher wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew Pitcher wrote:
dave windsor wrote:
Anil wrote:
>Hi,
>
>Where can I get the source code that has the implementation of the>below
>C operators/functions:
>malloc
>sizeof
>new
>strcmp
>strtok
>
>etc.,
>
>(any website points to the source code)
>
>I am using Linux OS with GCC as my C compiler.
>
>Thanks in advance,
>Anil.
If you are using a Linux system, as you say you are, the man command isuseful for finding out which files the source of a particular functionis in. In this case, since I know the files off the top of my head,I'll save you the work:
malloc() - stdlib.h


Wrong - stdlib.h contains some definitional values, but not the /source code/ for the malloc function.

sizeof() - this is actually an operator


True. To find out how it was implemented, the OP will have to read the source code of his C compiler.

new() [not an ANSI C function] - again, an operator


True. To find out how it was implemented, the OP will have to read the source code of his C++ compiler.

strcmp() - string.h


Wrong - stdlib.h

cut'n'past error: I meant to say "string.h"
contains some definitional values, but not the /source code/
for the strcmp function.

strtok() - string.h


Wrong - stdlib.h

cut'n'past error: I meant to say "string.h"
contains some definitional values, but not the /source code/
for the strtok function.

These files will be found in your C include directory.

The files you named will be found there. However, the files the OP is looking for are unlikely to be found in his C include directory.

- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFB79X3agV FX4UWr64RAoBnAJ 9Aeg55hojNNjPVI iN3Ugn26s6kcQCf TMWL
wsFUNOOhVEwXbBD FQna/+CQ=
=tFg3
-----END PGP SIGNATURE-----

My fault, I thought the OP was making a query as to the files he'd have
to include to make use of these functions. Obviously, "source code" for
each function would be found in their respective libc source file. Many
core functions have their own .h and .c file. For instance, the
implementation of malloc() is found in malloc.c. If the source files
for these functions exist on your system, they will be in your linux
source directory tree (usually /usr/src/linux). If not, download glibc
from http://www.gnu.org.

By the way, plz learn to quote properly.

Nov 14 '05 #6
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

dave windsor wrote:
Lew Pitcher wrote: [snip]
By the way, plz learn to quote properly.


I suggest that you either learn to read, or write a bug report to the Mozilla
foundation on the automated quoting process that Thunderbird uses. There's
nothing wrong with the way I quote - the attributions and related content were
intact, and my comments were inline, unquoted.
- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFB7/iFagVFX4UWr64RA s8yAKCnYlNXzSXL UU19U6tD11emEeM 4XwCfRSMD
0olKpVx41AGZj+c OuvAQ0UU=
=2y/V
-----END PGP SIGNATURE-----
Nov 14 '05 #7
There's no 'new' in C. sizeof is a C keyword, so download the source code
for your compiler and see how it is implemented. The others are part of the
C standard library, so download the source code for whichever C library you
are using and see how they implement the functions.

C doesn't proscribe how these things are implemented, only the semantics of
using them.

<posted & mailed>

Anil wrote:
Hi,

Where can I get the source code that has the implementation of the
below
C operators/functions:
malloc
sizeof
new
strcmp
strtok

etc.,

(any website points to the source code)

I am using Linux OS with GCC as my C compiler.

Thanks in advance,
Anil.


--
Remove '.nospam' from e-mail address to reply by e-mail
Nov 14 '05 #8
Lew Pitcher wrote:
dave windsor wrote:

[snip]
By the way, plz learn to quote properly.


I suggest that you either learn to read, or write a bug report to
the Mozilla foundation on the automated quoting process that
Thunderbird uses. There's nothing wrong with the way I quote - the
attributions and related content were intact, and my comments were
inline, unquoted.


I suspect that he was complaining about the lack of snippage, and
the fact that there was no blank line between the quotation and
your comment.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

Nov 14 '05 #9
dave windsor <nu******@gmail .com> scribbled the following:
By the way, plz learn to quote properly.


B th w, pls lrn t s vwls.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"C++. C++ run. Run, ++, run."
- JIPsoft
Nov 14 '05 #10

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

Similar topics

11
677
by: ma740988 | last post by:
How would I modify the TEST_CMD function to essentially return the appropriate status? Simply put. TEST_CMD could return either status1 or status2. The return value will be passed to the Write function inside main. The prototype for the Write function is highlighted below. #define TRUE 1 #define FALSE 0
8
1687
by: farhanb | last post by:
hello, I am writing a simple linked list implementation. When I use function insert1 I must allocate to head in my main to get it to work otherwise list stays empty but when I use function insert2 there is no need to allocate to head this is the correct way. why does this happen? why do we need to have a pointer to a pointer to head in...
6
3656
by: sathyashrayan | last post by:
#include<stdio.h> #include<stdlib.h> #include<string.h> struct tree { int data; struct tree *left,*right; }; void init(struct tree *node)
41
3311
by: jacob navia | last post by:
In the C tutorial for lcc-win32, I have a small chapter about a debugging implementation of malloc. Here is the code, and the explanations that go with it. I would appreciate your feedback both about the code and the associated explanations. ---------------------------------------------------------------------
10
2981
by: javuchi | last post by:
I just want to share some code with you, and have some comments and improvements if you want. This header file allocates and add and delete items of any kind of data from a very fast array: #include <stdlib.h> #ifndef __LIST_H__ #define __LIST_H__
52
3334
by: ¬a\\/b | last post by:
is it possible that a malloc function that use a nobody student is better than all yours :) How many errors do you see? Bug1: memory<13MB Bug2: it seems do you have to write you own sprintf "Ps_m" Ps_m(char* out, int len, char* fmt, ...)
5
2550
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I use to run a UM program, I kept on getting error messages. I have used someone else's implementation and it runs fine. I have compared my code...
7
2157
by: somenath | last post by:
Hi All , As a process of my C language learning I was trying to learn how malloc can be implemented from K&R2 .But I am not able to understand few points . It would be very much helpful if some body give some inputs in the bellow mentioned points. Point 1) I page 186 it is said that "In malloc, the requested size in characters is...
2
2849
by: Gestorm | last post by:
Suppose we have an array a, the idea is: build another array, int next, for each 0<i<N, next = next position of a in the sorted array, if a is the max, then next is undefined. For example, let the unsorted array is a = {5, 4, 2, 1, 3}; then next would be {undefined, 0, 4, 2, 1} after sorted.
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.