LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2003, 06:40 PM   #1
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
structs and allocation of mem


C code:
Code:
	struct member {
		int i;
		struct mem *next;
	} list;
		
	struct member *p = (struct member *) malloc (sizeof (struct member));
im not sure when memory is allocated above. does mem get allocated when i declare "list" (im thinking yes). in that case, would the malloc for the pointer be an extra block of memory for the same object?

as always, thanks a lot.

Last edited by h/w; 12-21-2003 at 07:09 PM.
 
Old 12-21-2003, 07:12 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Original Poster
Rep: Reputation: 46
pls disregard my question (i think its about time for a break).
 
Old 12-21-2003, 10:31 PM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
heh heh heh i know exactly how u feel
 
Old 12-22-2003, 03:34 AM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
ahh damn, wanna see how dumb i am? i was writing this asm routine to print out a string to stdout. first the function would append a newline to the string tho. now its supposed to first get the string length, then move in a newline character(hex 0xa) into the last byte where the NULL would usually be. soo, for the last 30 friggin minutes my dumbass kept trying to figure out why my string length function was returning 0 when it was workin fine b4. turns out i was doing this:
movl $0xa, (%ecx, %eax, 1) ;//add a newline where NULL terminator would be

instead of
movb $0xa, (%ecx, %eax, 1) ;//add a newline where NULL terminator would be

so i was moving in 0x0a000000 and trashing the rest of my strings on the stack, instead of just moving in a single by 0x0a!!! uuh duhhhhhhhhhhhhhh!! *checks clock, 4:30 am!!!* fsck maybe this has something to do with it!!! lol
 
Old 12-22-2003, 12:21 PM   #5
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Original Poster
Rep: Reputation: 46
heh, i think i need a break from computers for a while. last sunday, i didnt have internet connection, and it was like i hit a wall alluva sudden. i dont know what a day is like anymore without my laptop or a computer someplace. ive turned into one of those guys who looks at the cheap travel ads in the metro talkin bout gettin away from the computer to some touristy place, and dreams bout it. lol
not good.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copy structs in c alaios Programming 10 09-10-2005 02:31 PM
structs & scope jnusa Programming 6 11-16-2004 05:33 AM
pointers to structs in C spuzzzzzzz Programming 5 06-03-2004 05:41 PM
static structs? simbo Programming 3 02-05-2004 04:00 AM
Self referential structs in C? MadCactus Programming 14 01-28-2004 05:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration