A pointer to an array of pointers 
Author Message
 A pointer to an array of pointers

    Hi all.

  I am working with an API that has a function. The function returns a
pointer to a dynamic array of pointers to strings. The array can be of
any size. There is no maximum size of the array. The C declaration is
char ** . I am thinking of using a &CSTRING. I can get the number of
array elements at runtime.

So I can do a pbuff &= NEW(CSTRING((elements*4)+1))
Then do memcpy from memory into pbuff.
Then do some string slicing (which I don't think will actually work)
into a LONG.

Does anyone have any ideas. I would love to be able to pbuff &=
LONG,DIM(elements).

Ron



Thu, 13 Mar 2003 03:00:00 GMT  
 A pointer to an array of pointers
I think I would use memcpy to read from the list of pointers into a cw
long. Then use lstrcpyn to copy what the pointer points to into a queue
buffer then add to the queue.  Since you dont know how many strings are
comming as long as you can guess the max length of each string or a
safe number, then a queue allowing any number of entries sounds ideal.
----
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com


Thu, 13 Mar 2003 03:00:00 GMT  
 A pointer to an array of pointers
Jim,

  I am wondering the best way to store the list of pointers. Or even to
access them the best way.

  mySQLRow        LONG        ! Pointer to the array of pointers which are
the Fields in the Row
  numFields            UNSIGNED    ! Number of Fields in the Row

  numFields  = mysql_num_fields(result)
  mySQLRow  = mysql_fetch_row(result)

  I want to loop through the array of pointers getting each field. What can
I store the array into? Can I use a CSTRING? Or can I do something like
Igor Kuklin did with a Pointer Group?

  pgr                GROUP,TYPE
  x                      LONG,DIM(1)    ! Array index checking turned off
                      END

  That way I can access by pgr.x[1]
  What would be the best way to implement this?

  Ron

Quote:

> I think I would use memcpy to read from the list of pointers into a cw
> long. Then use lstrcpyn to copy what the pointer points to into a queue
> buffer then add to the queue.  Since you dont know how many strings are
> comming as long as you can guess the max length of each string or a
> safe number, then a queue allowing any number of entries sounds ideal.
> ----
> Jim Kane  - TeamTopSpeed
> Productive Software Solutions
> Can't Find that Message?
> Get Organized, Get ForKeeps!
> www.fkeeps.com



Thu, 13 Mar 2003 03:00:00 GMT  
 A pointer to an array of pointers
OK. After wringing out my Brain, I finally got it to work. Thanks to all
who helped and also to Igor Kuklin about his solution for dynamic arrays.

  Ron

Quote:

>     Hi all.

>   I am working with an API that has a function. The function returns a
> pointer to a dynamic array of pointers to strings. The array can be of
> any size. There is no maximum size of the array. The C declaration is
> char ** . I am thinking of using a &CSTRING. I can get the number of
> array elements at runtime.

> So I can do a pbuff &= NEW(CSTRING((elements*4)+1))
> Then do memcpy from memory into pbuff.
> Then do some string slicing (which I don't think will actually work)
> into a LONG.

> Does anyone have any ideas. I would love to be able to pbuff &=
> LONG,DIM(elements).

> Ron



Thu, 13 Mar 2003 03:00:00 GMT  
 A pointer to an array of pointers
theaddress long
savecstringq queue
acstring cstring(SomesafeBigNumber)
  end
loop i=0 to NumFields-1
  adr=mysqlrow+i*4
  memcpy(address(TheAddress),adr,4)
  if theaddress then
    lstrcpyN(address(SaveCstringQ.Acstring),theaddrress,|
    size(SaveCstringQ.Acstring)-1)
    add(SaveCstringQ)
  end
end  

Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com



Fri, 14 Mar 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. A couple of simple pointer questions (targets, arrays of pointers)

2. ISO C Binding: Pointer to a pointer of pointers: ***argv

3. Ada83 array of pointers to unconstrained array type

4. DEALLOCATE of a derived type array containing pointer array components

5. Pointers to pointers possible?

6. Pointer to pointer with LabVIEW 4.1?

7. pointers and pointers.

8. Returning Pointer To Pointer From Function

9. Implementing pointers to pointers in Ada

10. pointer to pointer to field / dynamic field

11. Deallocation of a pointer which points to a type containing allocated pointers

12. fortran 90/95 pointers vs C pointers

 

 
Powered by phpBB® Forum Software