Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Wednesday October 20, 2004
06:55 PM

obstacks

[ #21440 ]

I'm using C in school again. Lots to relearn ... I was under the impression you can't truly return a struct or any complicated data structure that didn't boil down to a basic data type or pointer, but apparently I was wrong.

And suddenly I'm learning more about malloc() than ever before. There are things I'd heard about but never investigated in detail, because I always knew I could look them up if I needed to. Tonight I had to look up the mallinfo() function (which I presume is a GNU extension) in order to report on how much memory malloc was using.

Anyway, I saw something in the GNU libc manual that mentioned sbrk, which if I understand correctly is the assembly instruction (or very low level C function) used in some way to implement malloc(), and I decided that while my long program was running its next trial, I could look through and learn how that works. But I got distracted along the way when I saw obstacks, which I'd never heard of before, and sounded interesting because they appear to represent an alternative to malloc().

I haven't actually read much about them, yet, but I'm curious: has anyone here ever used these before? For that matter, has anyone here ever even heard of them before? Are they a GNU extension to libc, or something standard?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'm using C in school again. Lots to relearn ... I was under the impression you can't truly return a struct or any complicated data structure that didn't boil down to a basic data type or pointer, but apparently I was wrong.

    Passing and returning structs has been around since the ANSI C standardization in the 80's, I think. The GNU compiler of the day was one of the first to provide that extension but it was fairly common. I can recall one compiler, perhaps it was pcc, allowing only structs that were sm