From: "J." <mailing-lists@xs4all.nl>
To: linux-c-programming@vger.kernel.org
Subject: obstack_alloc & _obstack_newchunk
Date: Wed, 23 Feb 2005 13:45:35 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.21.0502231316180.1636-100000@hestia> (raw)
Wednesday, February 23
Hello, I am looking into the GNU's obstack lib .
Unfortunatly it segfaults. According to a backtrace of the program stack
it goes down at obstack_newchunk_ . To be honest I am kind a stuck here.
There is enough free memory available since I am able to write this
message... The only thing I can come up with is that obstack_alloc trys
to add new memory to the address of string_obstack, which isn't properly
setup by moi.. ?
#include <stdio.h>
#include <string.h>
#include <obstack.h>
struct obstack string_obstack;
char *copystring(char *string);
int main(void) {
char *orig = "to copy this string";
char *str = NULL;
str = copystring(orig);
printf("%s\n", str);
return 0;
}
char *copystring(char *string) {
size_t len = 0;
char *s = NULL;
len = strlen(string) + 1;
s = obstack_alloc(&string_obstack, len);
memcpy(s, string, len);
return s;
}
Thnkx..
J.
--
http://www.rdrs.net/
next reply other threads:[~2005-02-23 12:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-23 12:45 J. [this message]
[not found] <NHBBKOOOHBAAJLGEOFLHEENEPJAC.moremari@aca.org.ar>
2005-02-23 13:37 ` obstack_alloc & _obstack_newchunk J.
2005-02-23 22:49 ` Rechberger Markus
2005-02-24 9:04 ` J.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.21.0502231316180.1636-100000@hestia \
--to=mailing-lists@xs4all.nl \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).