I think that whole step is unnecessary (saving the reference into a "d_ptr" pointer). Just pass `f.d_head` directly to the pst_parse_item() function.
On Thu, Aug 23, 2012 at 1:50 PM, rhasson <rhas...@gmail.com> wrote: > Sorry for not being very clear. You're correct, pst_file is a struct with > d_head being a pointer to another struct. Within libpst (the C library I'm > working with), when you call pst_open() you pass pst_file by reference which > opens the PST file (MS outlook file) and populates the pst_file struct. > d_head is a pointer to another struct that holds individual records pulled > out of the PST file. When the pst_open() call returns I need to take the > d_head pointer, assign it to another pointer variable of type pst_desc_tree > and use that to pass into another function. > > pst_item *item = NULL; > pst_desc_tree *d_ptr; > > pst_open(&pstfile, file_name, NULL); > d_ptr = pstfile.d_head; // first record is main record > item = pst_parse_item(&pstfile, d_ptr, NULL); > > The way I did it which seems to work is: > > var f = new pst_file(); //the main pst_file struct > var pstdesctree_Ptr = ref.refType(pst_desc_tree); > var d_ptr = ref.alloc(pstdesctree_Ptr); > ref.writePointer(d_ptr, 0, f.d_head); > > This seems to copy the correct pointer, however when I do: > ref.deref(d_ptr) > I get a segmentation fault. > How would I get access to the variables stored in that struct inside node? > > Here is my code: https://github.com/rhasson/node-libpst > I didn't finish converting all the structs yet but give you an idea of what > the code looks like. In the SRC directory I included the .c and .h files so > you can see the structures. > > Thanks, > Roy > > On Thursday, August 23, 2012 1:15:15 PM UTC-4, Nathan Rajlich wrote: >> >> > In C I do this: >> > typedef struct pst_file { >> > pst_desc_tree *d_head >> > } pst_file; >> > >> > pst_desc_tree *d_ptr; //this is another struct >> > d_ptr = pstfile.d_head; >> >> It's a pointer to a struct actually. I think you need to explain more >> what you intend to do with the variable after. Are you trying to make >> a duplicate of the struct? It seems to me that what you have above >> would be achieved with "pstfile.d_head.slice(0)" but I can't really >> imagine what you would need that for. > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en