I think this might have been a memory violation issue. I was attempting to access a NULL struct later in the thread and I'm guessing this could have potentially violated memory?
Type: Posts; User: rotis23
I think this might have been a memory violation issue. I was attempting to access a NULL struct later in the thread and I'm guessing this could have potentially violated memory?
Yes thanks - I can see MAX_THREADS+1 but not num_threads < 0.
Something very weird going on here...I've seen the debug printf line output MAX_NUM_THREADS+1 !
How is that possible? Either I've implemented the mutexes wrong or they're not working properly.
Thanks for the input.
num__threads should be num_threads in my code fragment.
num_threads does not change anywhere else.
Was thinking of doing that change - much more readable ;)
BTW -...
What does pthread_create return?
Find out where it's freezing by using gdb or strace and attaching to the running process using the '-p' option.
Hi All,
Consider this [multi-threaded] code fragment...
int volatile num_threads = 0;
snip...
alright :/
Thanks Kurt.
Fair enough Salem but I've got a load of win32 code in my app :/
Can I just get something really clear with reference to my previous lump of code:
struct base
{
char *string;
};
http://www.cs.toronto.edu/~heap/270F02/node31.html
Should be the following according to the above link:
my_parent = (struct parent *)malloc(sizeof(struct parent));
doesn't like that either:
Error E2108 struct.c 12: Improper use of typedef 'parent' in function main()
Error E2109 struct.c 12: Not an allowed type in function main()
Error E2034 struct.c...
Borland Windows compiler doesn't like a cast'less malloc:
my_parent = malloc(sizeof(parent));
fails with:
Compilation is not dependent on correct memory allocation - that's why we see run time memory errors.
thanks Grumpy - Dave beat you to it slightly. I don't want to copy the string just point to it.
And the correct way to allocate mem for a pointer to a struct is?
parent = (struct parent*)malloc(sizeof(struct parent*));
Or should I be using calloc ahluka? I don't want to start the...
Yes - of course the problem was allocating space for the parent pointer - thanks Dave.
OK - this works OK:
struct base
{
char *string;
};
struct parent
No - because it's pointing to an existing char* at the time of the printf. Maybe this is where I'm going wrong?
Segmentation fault on Linux.
Thanks for your help Kurt.
Hi All,
Sorry - this is my second nested data structure post today :)
struct base
{
char *string;
};
Yes - I have that correct in my other code :/
Is the remaining code valid?
Hi All,
Can someone tell me if this is the correct way to create, reference and allocate mem for this data?
int main()
{
char *char_table[2][1];
This quote from this url seems to support my theory:
Anyone shed any more light on this?