hej!

  got to the upper limits of size :)) time to be more dynamic.. 

  this is a normal section of standard C code for allocating
  a 10x10 array of characters.

  ---
  {
    char **myStrings;
    int  i, count;

    // allocate the memory

    count = 10;
    myStrings = (char **)malloc(count * sizeof(char *));
    for (i=0; i<count; i++) {
      myStrings[i] = (char *)malloc(10 * sizeof(char));
      sprintf(myStrings[i], "%d", count);
    }

    // do something

    ...

    // free the memory

    for (i=0; i<count; i++) {
      free(myStrings[i]);
    }
    free(myStrings);
  }
  ---

  a direct port to the palmOS i thought would be like
  this:

  ---
  {  
    CharPtr *myStrings;
    int  i, count;

    // allocate the memory
     
    count = 10;
    myStrings = (CharPtr *)MemPtrNew(count * sizeof(CharPtr));
    for (i=0; i<count; i++) {
      myStrings[i] = (char *)MemPtrNew(10 * sizeof(Char));
      StrIToA(myStrings[i], count);
    }
  
    // do something (like set the values in a pull down list)

    LstSetListChoices(listP, myStrings, count);

    // free the memory
         
    for (i=0; i<count; i++) {
      MemPtrFree(myStrings[i]);
    }
    MemPtrFree(myStrings);
  }
  ---

  but this gives me unallocated memory errors.. 

  any pointers? should i be allocating memory to
  handles and then lock those handles to pointer 
  references?

  the API says the following for MemPtrNew:

---
  Allocate a new nonmovable chunk in the dynamic heap.
---

  does my code "move" the chunk of memory? :)

  cheers.

az.
--
Aaron Ardiri 
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN       
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 352 8192           A/H: +46 26 10 16 11

Reply via email to