HDTenEightyP/NetNews huggingface dataset:
From: abuhr@owlnet.rice.edu (Aaron M. Buhr)
Subject: Re: Help me track down memory leakage
Organization: Rice University
Date: Tue, 24 Nov 1992 01:33:43 GMT

In article <By6G98.68L@rice.edu> abuhr@owlnet.rice.edu (Aaron M. Buhr) writes:
>     As it turns out, I am having a strange error that I cannot figure
>out.  The dbg_malloc and dbg_free routines seem to be working fine, in
>that they return pointers to valid-sized memory blocks and free those
>memory blocks, and it seems that those blocks can be manipulated
>directly or by some library calls (strcpy for example).  However, for
>some reason sscanf() returns a bus error when I try to use it on one
>of the blocks the dbg_malloc() routines returned (the sscanf() works
>fine with the regular C library malloc() routine).  Here's the gdb
>output:


    Many thanks to Jim Segrave, who pointed out that the size of the
debugging block I was adding onto every allocated memory block had an odd
size.  This caused all returned memory pointers to point to odd addresses.
The memory blocks worked fine with byte accesses, but as soon as I tried to
manipulate the blocks as integers the program died with a bus error.
Apparently, on Sun 4s all integer accesses must be word aligned.  Changing
the size of the filename space from 20 to 19 then decreased the size of the
debugging block from 33 to 32, a nice, divisible-by-4 number, and caused the
returned pointers to be properly aligned for integer accesses.
    I'm fixing up a bunch of other typos in the code, and when I'm done
debugging and enhancing the package I'll probably post it to one of the
.sources newsgroups.  It's going to remain a simple, easy-to-use memory
tracking routine, since there seem to be several large, full-featured
products already available.  Thanks again to all that helped me out on this.
Hopefully I'll finally be able to get rid of all those darn memory leaks. :)


Aaron Buhr
abuhr@owlnet.rice.edu

Xref: sparky comp.lang.c:16630 comp.std.c:3014
From: corvett@cs.bu.edu (Sungyeup Kim)
Newsgroups: comp.lang.c,comp.std.c
Subject: Search function algorithms
Date: 17 Nov 92 03:59:45 GMT
Followup-To: comp.lang.c
Distribution: comp
Organization: Computer Science Department, Boston University, Boston, MA, USA


Hi, 
Could somebody give me a very nice and easy search algorithm. 
What I want to do is after I get a string(I don't know the length) 
I want to check whether it's in the array or not.

Thanks in advance !!!
Newsgroups: comp.lang.c
From: alan@sal.wisc.edu (Alan Watson)
Subject: Re: putenv question
Organization: Space Astronomy Lab, Madison WI
Distribution: na
Date: Tue, 24 Nov 1992 03:23:14 GMT

In article <1992Nov23.204330.13594@news.miami.edu> aem@news.miami.edu (andrew mossberg) writes:
>
>I'm trying to read a file and place lines found there into the environment
>via putenv, but it isn't cooperating.  It works fine when I hardcode
>values into the putenv calls, like putenv("SSS=adas");, but reading
>a file using fgets() and then putenv'ing the line (sans trailing newline)
>only leave the last line in the environment.

When you use putenv, the argument string becomes part of the environment;
consequently, if you change the contents of the string (by reading another
line), you will overwrite your previous change.

Try malloc-ing a new string for each line.
Newsgroups: comp.lang.c,comp.lang.c++,alt.tasteless.jokes,rec.humor
From: mjn@pseudo.uucp (Murray Nesbitt)
Subject: Re: *** IMPORTANT DISCOVERY ***
Organization: Private system in Toronto, ON
Date: Mon, 16 Nov 1992 06:08:38 GMT

knaggs@cps.msu.edu (Scott A Knaggs) writes:

> "Will you do anything for me?", I asked. "Yes", was your answer. I asked you
> to lay down. You did. I squated right above your head and again, your tongue
> started to do it's job. You heard me make a strange noise: "NNNNNNGGGGG".
> You thought it was my extasy, but you soon found out it was something else.
> You felt something drop on your nose, something which slid slowly into your
> mouth. Your curious tongue tried to find out what it was. Congratulations,
> you just tasted a piece of shit! You really liked it. It turned you on even
> more and I started to grap some off your head and massaged your dick
> with it. Your dick looked great, nice and brown with little lightbrown thick
> pieces on it.  I started to give you a blow job. I really enjoyed the taste
> of cock combined with shit. Especially after you came... I turned around with
> my mouth full and kissed you. I emptied my mouth in yours. You passionately
> returned my kisses. After that we layed in each others arms for minutes.
> You had a big smile on your face.

Not if you want your code to be portable to other compilers.  Some
compilers, notably gcc, have extensions to the language that make this
kind of thing possible, but in the majority of implementations this
code will result in undefined behavior.

-- 
Murray
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: Memory Info.
Date: 24 Nov 1992 01:57:52 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

In article <3900@dozo.and.nl> jos@and.nl (Jos Horsmeier) supplies code
to remember allocation sizes.  The code is mostly right, but makes use
of one ``gcc feature'' (or other system-specific feature):

>		((char*)object)+= SLOTSIZE;	/* step over size slot */

This should be:

	object = (size_t *)((char *)object + SLOTSIZE);

and:

>		((char*)object)-= SLOTSIZE;	/* object points to size */

this should similarly be:


	object = (void *)((char *)object - SLOTSIZE);

The outer cast (to (void *)) can be omitted in this case.

>SLOTSIZE is a manifest constant that has to obey to the following rules:
>
>- SLOTSIZE >= sizeof(size_t)
>
>- SLOTSIZE is the smallest multiple of the most stringent alignment
>  size needed on your machine, e.g. on a SPARC the alignment of a double
>  is 8 bytes (the most stringent alignement), where the alignment of a
>  size_t is 4 bytes, so SLOTSIZE would be 8 in this situation. 

Note that there is no portable way to discover this number.  If you
know what kinds of objects you will allocate, you can discover the
alignment needed for those using a union; but otherwise---and usually
even when this is so---the only thing to do is include some
machine-dependent information.  On 4.4BSD-based systems, you can

	#include <machine/param.h>

to get two macros called ALIGN and ALIGNBYTES:

/*
 * Round p (pointer or byte index) up to a correctly-aligned value for
 * the machine's strictest data type.  The result is u_int and must be
 * cast to any desired pointer type.
 */
#define ALIGNBYTES	7
#define ALIGN(p)	(((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)

(Note that the result type of ALIGN() is in fact machine-dependent; as
a user you are really only supposed to know that, while you can feed it
either pointers or integers, you have to cast it if you want a pointer
back.)
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov
Newsgroups: comp.lang.c,comp.lang.c++,alt.tasteless.jokes,rec.humor
From: aorpha@spock.uucp (Andreas Orphanides)
Subject: Re: *** IMPORTANT DISCOVERY ***
Organization: Choate Rosemary Hall
Date: Wed, 18 Nov 1992 23:59:59 GMT

In article <1992Nov16.221156.18458@spock.UUCP> kurgan@spock.uucp (Andrew Twyman) writes:
>In article <1992Nov13.210911.3086@msuinfo.cl.msu.edu> knaggs@cps.msu.edu (Scott A Knaggs) writes:
>>"Will you do anything for me?", I asked. "Yes", was your answer. I asked you
>>to lay down. You did. I squated right above your head and again, your tongue
>>started to do it's job. You heard me make a strange noise: "NNNNNNGGGGG".
>>You thought it was my extasy, but you soon found out it was something else.
>>You felt something drop on your nose, something which slid slowly into your
>>mouth. Your curious tongue tried to find out what it was. Congratulations,
>>you just tasted a piece of shit! You really liked it. It turned you on even
>>more and I started to grap some off your head and massaged your dick
>>with it. Your dick looked great, nice and brown with little lightbrown thick
>>pieces on it.  I started to give you a blow job. I really enjoyed the taste
>>of cock combined with shit. Especially after you came... I turned around with
>>my mouth full and kissed you. I emptied my mouth in yours. You passionately
>>returned my kisses. After that we layed in each others arms for minutes.
>>You had a big smile on your face.
>
>Not only is this too sick to be on rec.humor (which isn't necessarily bad),
>but it's nauseating and DUMB!  Keep it out of my face.  You're even more of a
>pervert than I am, and that's a sick thought.
>-- 
>-------------------------------------------------------------------------------
>|  -"I have something to say.  It's better to burn out, than to fade away!"-  |
>|                          -* THERE CAN BE ONLY ONE *-                        |
>kurgan@choate.edu--------------------------------------------------------------

Well, my aarch-nemisis, i see that in one field we agree.

PERVERTS SHOULD BE KEPT OFF THE NET. man, that paragraph is grosser than kurgan's (in real life) face!

ramirez (soon)
aorpha@choate.edu
.sig pending
Xref: sparky comp.lang.c:16664 comp.unix.questions:13513
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c,comp.unix.questions
Subject: Re: name of file descriptor
Date: 17 Nov 92 12:59:31 GMT
Followup-To: comp.unix.questions
Organization: McGill Research Centre for Intelligent Machines

In article <1992Nov16.122835.16126@alf.uib.no>, singg@alf.uib.no (Kurt George Gjerde) writes:

> How can I get the filename from a filedescriptor, on Unix??

This is a UNIX question, not a C question, and I'm therefore
crossposting to comp.unix.questions and redirecting followups there.

In general, you can't.  The file descriptor may not be connected to a
file (it may be a pipe or (other) socket or TLI stream or a device or
maybe something else).  Even if it is a file, the file may have no
names any longer, or it may have multiple names.  Even if it has at
least one name, there may be no name by which it is accessible to your
process or possibly even other processes.  And even if you assume it
has a name that you could use to refer to it by, there is no way to
find any such name short of a full scan of all filesystems, which can
take a *long* time.

You're usually best off writing wrappers for open/close (or
fopen/fclose if you're using stdio) that remember filenames.  The major
case where this doesn't work is when you're dealing with redirection to
or from files, in which case you're pretty much out of luck.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
From: gs32+@andrew.cmu.edu (Geoffrey Spear)
Newsgroups: comp.lang.c
Subject: Re: Pascal as C prelude?
Date: 22 Nov 92 14:57:48 GMT
Article-I.D.: andrew.Yf42mAC00iUxA4mKIu
	<1992Nov22.230514.4991@umbc3.umbc.edu>
Organization: Freshman, CIT general, Carnegie Mellon, Pittsburgh, PA

if(condition){
    statement1;
    statement2;
}

Is easier for ME, at least to read.  First of all, it saves vertical
space, which is great if you're using EMACS on a 24x80 screen and don't
want large chuncks of code to scroll off your screen because of 50 lines
wasted on }'s.  Secondly, a line with just a { on it is pointless, as
you will see that the block ends with the } (nicely justified under the
statement which required the {}'s in the first place) even if you happen
to miss the first {.

    Finally, and most importantly (to me at least :) ), your style
reminds me of Pascal, and I try to avoid being reminded of Pascal at all
costs :).

------------------------------------
Geoffrey Spear
Dept. of Electrical & Computer Engineering
Carnegie Mellon University
------------------------------------
"You're redlining my bogometer!!"
Newsgroups: comp.lang.c
From: sca@gese.ge14.mdadv.gv.at (Petzi Schweda)
Subject: Re: Int,short int and portability of code
Organization: MD-ADV, Vienna, Austria
Date: Tue, 17 Nov 1992 09:07:49 GMT

My experiences in porting code (from VAX/VMS with 4-byte ints to MS/DOS/WOINDOWS with 2-byte ints) were that you can avoid most of the problems by explicitliy declaring your variables as "short" or "long".
Well, most but not all problems: a whole bunch of library routines (i.e. printf, memcpy) take an int as parameter. And therefore int's have to be the size the library is expecting, right ?
To be honest: with printf (and vprintf for variable arglists) my aproach was VERY empiric ...

regards, Petzi
-- 
Petzi Schweda (sca@gese.ge14.mdadv.gv.at)
MD-ADV, Municipality of the City of Vienna, Austria
From: fischer@iesd.auc.dk (Lars Peter Fischer)
Newsgroups: comp.lang.c
Subject: Re: The Correct Way To Write C if-Statements
Date: 17 Nov 92 03:40:50 GMT
	<craigh.721691551@cserver>
	<1992Nov15.200637.20480@thunder.mcrcim.mcgill.edu>
Organization: Mathematics and Computer Science, Aalborg University


>>>>> "dM" == der Mouse (mouse@thunder.mcrcim.mcgill.edu)

dM> In typeset material, spaces don't occur in nice integer units, so "one
dM> space" versus "two spaces" makes no sense. [...]

And anyway, I believe I have the right to expect the software I use to
handle this for me automagically.

/Lars
--
Lars Fischer, fischer@iesd.auc.dk | It takes an uncommon mind to think of
CS Dept., Aalborg Univ., DENMARK. | these things.  -- Calvin
From: tcobbs@zeus.calpoly.edu (Travis Cobbs)
Newsgroups: comp.lang.c
Subject: Re: pointers to functions
Keywords: pointers functions parameters
Date: 22 Nov 92 00:08:43 GMT
Distribution: na
Organization: California Polytechnic State University, San Luis Obispo

In article <DU28YHO@math.fu-berlin.de> rene@hamel.uucp (Rene Mueller) writes:
>In article <1992Nov6.234729.13866@koko.csustan.edu>, pendell@deneb.csustan.edu (Brian Pendell) writes:
stuff deleted
>|> double (*pfun) ();
>|> 
>|> Now, how do I call the function using the pointer? That is, the next
>|> 
>|> instruction should be:
>|> 
>|> "Call the function pointed to by pfun with parameters A and B"
>|> 
>|> function (A,B), in other words.
>|> 
>|> Any suggestion?
>|> 
>|> 
>|> 	-- Brian Pendell (pendell@ceti.csustan.edu)
>
>the same way you reference EVERY pointer:
>(*pfun)(paramlist);
>you must write (*pfun)() cause funktion calling has a higher priority than
>dereferencing pointers...
>
>	Rene

Actually, you don't need to use (*pfun)(), you can just use pfun().  C
interprets them both the same way, since there's no other logical thing to do
with a function call except call the function.
+-----------------------------------+------------------------------------------+
|                      Travis Cobbs | When you have to kill a man, it costs    |
|           tcobbs@nike.calpoly.edu | nothing to be polite.                    |
|       tcobbs@morpheus.calpoly.edu |   --Winston Churchill, On formal         |
|    tcobbs@polyslo.csc.calpoly.edu |     declarations of war                  |
+-----------------------------------+------------------------------------------+
Newsgroups: comp.lang.c
From: hansm@cs.kun.nl (Hans Mulder)
Subject: Re: Virtual memory Management Systems
Organization: University of Nijmegen, The Netherlands
Date: Wed, 18 Nov 1992 19:28:33 GMT

In <1992Nov18.081123.29057@di.unipi.it> Nico Tranquilli <ntranqu@caticsuf.cati.csufresno.edu> writes:

>Perhaps I should have asked : "What is the name of HARDWARE devices
>which allocate virtual memory on disks whenever the internal memory
>become full ?

They are called Central Processing Units, or CPUs for short.

--
Hans Mulder			hansm@cs.kun.nl
From: clive@x.co.uk (Clive Feather)
Newsgroups: comp.lang.c
Subject: Re: Idle Questions about ANSI C
Date: 18 Nov 92 12:52:32 GMT
Organization: IXI Limited, Cambridge, UK

In article <1992Nov17.123803.6400@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
> Now: is it required that size_t be the same as one of the four usual
> unsigned integral types?  (How about ptrdiff_t?)

Yes. The term "integral type" *has* [1] to be read as defined in 6.1.2.5.
An integral type is:

    char
    a "signed integer type"
    an "unsigned integer type"
    an enumerated type

a signed integer type is:

    signed char
    short int
    int
    long int

an unsigned integer type is:

    unsigned char
    unsigned short int
    unsigned int
    unsigned long int

size_t must be an unsigned integral type and ptrdiff_t a signed one. I
don't think anything can be read into the use of "integer" in one place
and "integral" in another.

[1] It says so at the start of section 3 (ISO).


-- 
Clive D.W. Feather     | IXI Limited         | If you lie to the compiler,
clive@x.co.uk          | Vision Park         | it will get its revenge.
Phone: +44 223 236 555 | Cambridge   CB4 4RZ |   - Henry Spencer
Fax:   +44 223 236 550 | United Kingdom      |
Newsgroups: comp.lang.c
From: u920496@daimi.aau.dk (Hans Erik Martino Hansen)
Subject: portable UNIX programs
Summary: distribuate applications as pseudo machineindependent assemblercode
Keywords: binary port unix
Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
Date: Fri, 20 Nov 92 17:47:44 GMT

I have often wondered why software packages for Unix, was
distribuated as binary code. Why not distribuate it as 
in a machine independant format. It is obvious that no software
company wants their source code accessable for everybody.
But if a standard was made for a sort of machine independent
pseudo assemblercode, which could be compiled on any
UNIX-installation then Unix became the true machine independent
operating system, which was intended in the first place.

Of course there would be a need for a more strict definition of
the Unix operation system, compared to today. But imagine
the advantages. If at the same time Unix became
a smaller system, it would suddenly become very competetive
to DOS/Windows, Machintosch and other microcomputer operating
systems. And perhaps in the end become the one and only OS.

Please comment my idea, thanks.

Erik M. Hansen            |Email: u920496@daimi.aau.dk
Trige Parkvej 9, ST 1     |I study Computer Science at the
DK-8380  Trige            |Aarhus University, Denmark
Denmark, Europe           |"Information wants to be free"
---------------------------------------------------------------
Newsgroups: comp.lang.c
From: cschen@csie.nctu.edu.tw (Chih-Shen Chen)
Subject: HELP! with WATCOM C and PharLap 386|DOS-Extender
Organization: National Chiao Tung University
X-Newsreader: TIN [version 1.1 PL6]
Date: Sat, 21 Nov 1992 09:07:17 GMT

Hi, there

	With WATCOM C/386 and PharLap 386|DOS-Extender, I failed to change
the interrupt vector in protected mode.  WATCOM C/386 is new to me.  So I 
am wondering if there's anyone be so kind to give me some help, I will will
sincerely appreciate that.

	I am currently using WATCOM C/386 with PharLap ASM|386, LinkLoc,
and 386|DOS-Extender.  And I  need to change the service routine of packet
driver interrupt.  First, I tried to use _dos_setvect and _dos_getvect 
routines provided in library.  But they didn't work.  I don't know how 
exactly they function inside the library, and doubted that if it uses DOS
INT 21h function 25h in the same way as in real mode (only AH=25h).  After
checking up 386|DOS-Extender manual,  It seems that INT 21h should be called
with AX=2502h and AX=2504h to do these jobs.

	So I wrote two routines in assembly language to replace _dos_setvect
and _dos_getvect, and linked them with the C portions, but still in vain.
What misstaks have I made?  Did I miss something?  Any suggestion or info 
will be appreciated, and please reply via e-mail.  Thanks in advance.

--
Chih-Shen Chen			Internet: cschen@csie.nctu.edu.tw
+--------------------------------------------------------------------+
|  National Chiao-Tung University                                    |
|  Institute of CSIE, PDP Lab.                                       |
|  Hsinchu, Taiwan, R.O.C.                                           |
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
From: alan@hal.larc.nasa.gov (alan dare)
Newsgroups: comp.lang.c
Subject: Pointer to a short struct????
Date: 18 Nov 1992 22:00:50 GMT
Organization: NASA Langley Research Center, Hampton, VA  USA
Distribution: usa
NNTP-Posting-Host: hal.larc.nasa.gov
Originator: alan@hal.larc.nasa.gov


	I am mapping (mmap) a board that pulls information from an external
data bus into my programs address space. The data is in a packed format. 
Instead of using shifts and masks to extract the data I planed on using bit 
fields. Major Problem: A structure seems to have a minimum width of an 
integer (32 bits). However, the dual ported memory is 16 bits wide. Thus I 
can't use a structure/field pointer into the cards memory because I will not 
always be on a 32 bit word boundary (core dump: bus error). Currently I get 
around thus by copying the short word from the card into an integer and 
applying the pointer to the bit field to it. However, this requires that I 
copy each word from the 256K DYNAMIC memory (I'm reading an active bus and 
trying to decode and extract information). It's slow and painful to copy 
each short into an integer. The million dollar question is: Is it possible 
to have a structure smaller than a full word, like a short? If so whats
the declaration?

Thanks
-- 

*********************************************************************
Alan Dare                     |  Internet : alan@hal.larc.nasa.gov
NASA Langley Research Center  |
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Newsgroups: comp.lang.c
Subject: Re: ANSI testing for gcc
Date: 20 Nov 92 16:20:51 GMT
Organization: SAS Institute Inc.
Originator: sasghm@theseus.unx.sas.com


In article <1992Nov20.122420.20477@lambda.msfc.nasa.gov>, puckett@lambda.msfc.nasa.gov (Jim Puckett) writes:
|> ...so my boss says 'Is gcc ansi compatible? does it work?'
|> 
|> ...of course, he can man gcc as well as i can, and in fact did - and 
|> printed it out and left it on my desk, by way of reminding me that
|> he had asked the above question...8-)
|> 
|> ...and he can see -ansi and -pedantic as well as i can too....
|> 
|> ...but is there any way of _proving_ ansi compatibility/compliance? is 
|> there any test code for that sort of thing?....
|> 
|> humbly asking,
|> jim p.
|> -- 
|> Jim Puckett    NTI    puckett@lambda.msfc.nasa.gov     
|> Madison,AL (205)461-4922  
|> i need to ask myself.....
|> ***********         Would I rather be right, or happy?         ***********

Sure.  Call up Plum-Hall and get their current price on the test
suite.  Then tell him you need the test suite in order to answer
the question with complete accuracy.  His response will indicate
how serious he is.
-- 
Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
Newsgroups: comp.lang.c