473,398 Members | 2,403 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,398 software developers and data experts.

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 7562
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)

iD8DBQFB79WwagVFX4UWr64RArsSAJsFcO63VBb/MH3GH148ZH1iEskSuQCfQZp5
Pt7EpzUuLD9eK2rURod2Ods=
=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)

iD8DBQFB79X3agVFX4UWr64RAoBnAJ9Aeg55hojNNjPVIiN3Ug n26s6kcQCfTMWL
wsFUNOOhVEwXbBDFQna/+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)

iD8DBQFB79X3agVFX4UWr64RAoBnAJ9Aeg55hojNNjPVIiN3Ug n26s6kcQCfTMWL
wsFUNOOhVEwXbBDFQna/+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/iFagVFX4UWr64RAs8yAKCnYlNXzSXLUU19U6tD11emEeM4XwCf RSMD
0olKpVx41AGZj+cOuvAQ0UU=
=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.com, 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.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"C++. C++ run. Run, ++, run."
- JIPsoft
Nov 14 '05 #10
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
dave windsor <nu******@gmail.com> scribbled the following:
By the way, plz learn to quote properly.


B th w, pls lrn t s vwls.


Ll yr vwl r blng t s.

(Srr, cldn't rsst.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #11
Lew Pitcher wrote:
-----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/iFagVFX4UWr64RAs8yAKCnYlNXzSXLUU19U6tD11emEeM4XwCf RSMD
0olKpVx41AGZj+cOuvAQ0UU=
=2y/V
-----END PGP SIGNATURE-----


Interestingly enough, I deleted the post you're replying to in the
above post (unfortunately it had already made it through clc's and was
published). Why? I knew it'd generate unnecessary flamage. I was right,
FOUR posts directly related to the comment I made:
By the way, plz learn to quote properly.


Well, here's a fifth. Cheers to wasted bandwidth, time and triviality.

Perhaps a more tactful way to say what I was trying to express above
would be "Not to suggest that you are ignorant of the ways of usenet,
but quoting your own deleted post as a means of correcting
typographical errors is confusing; just post the original with the
corrections in place next time." I just thought, maybe, that you were
new to usenet and weren't aware of the precedents for posting that've
been in place for years. I was simply trying to indicate that you were
deviating from these precedents. The information you offered in your
reply is indeed very valuable, it's just formatted in a somewhat
counterintuitive way.

The fact that I felt compelled to type that last paragraph is
ridiculous. Suggesting *anything* to people is becoming quite tiresome.
-dave

Nov 14 '05 #12
Keith Thompson wrote:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
dave windsor <nu******@gmail.com> scribbled the following:
By the way, plz learn to quote properly.


B th w, pls lrn t s vwls.

Ll yr vwl r blng t s.

(Srr, cldn't rsst.)


Ll, jz, u gys r hv fn t. (Srr, jst hvng sm fn).

--
"I'm learning to program because then I can write
programs to do my homework faster." - Andy Anfilofieff
Nov 14 '05 #13

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

Similar topics

11
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...
8
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...
6
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
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...
10
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: ...
52
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...
5
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...
7
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...
2
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.