Omnimaga > Ndless

General Ndless Questions and Support

<< < (28/29) > >>

Levak:

--- Quote from: Matrefeytontias on January 21, 2013, 11:07:01 am ---This code crashes :
--- Code: ---int main()
{
  char *filename;

  if(show_msg_user_input("A", "B", "C", &filename) != -1) free(filename);
  return 0;
}
--- End code ---

--- End quote ---
It runs fine for me. Update your Ndless (on the handheld) to the latest.


--- Quote ---And I can't find any libndls directory in /ndless/ ... (I use the Ndl3ss SDK)

--- End quote ---
Okay ... in the sources, so here is the sample code :

--- Code: ---   const char * title = "Title";
   const char * msg = "Element";
   char * defaultvalue = "default value";
   char * value;
   unsigned len = show_msg_user_input(title, msg, defaultvalue, &value);
   if (len >= 0)
   {
      printf("%s (%d)\n", value, len);
      free(value);
   }
   else
      puts("Canceled");

--- End code ---

--- Quote ---EDIT : second question on the go : why does libndls's refresh_osscr() crashes ? :banghead:

--- End quote ---
Same, I think your Ndless version on the handheld is not up to date.


--- Quote from: hoffa on January 21, 2013, 11:31:36 am ---
--- Quote from: Levak on January 21, 2013, 10:19:18 am ---Indeed, you don't know its size and putting arbitrary size (here 256) is a bad programming behavior.

--- End quote ---
I don't want to be a nitpicker, but I have to disagree. In a practical context, using "big enough" buffers when dealing with arbitrary-sized strings is in many cases better than hassling around with a bunch of pointers and dynamically allocated memory. Using the latter method complexifies and bloats the code unnecessarily, gives the programmer additional responsibility (gotta compute the size of the data, malloc it, remember to free the memory, etc.), decreases the programs maintainability (as the code for that filename container is scattered around, when modifying bigger chunks better check it doesn't cause any undefined behavior), and generally the whatever academic perfection of the code doesn't outweigh the pain of dealing with such trivial stuff. We're not talking about security-critical government-class programs here, and it's not like there aren't any functions to avoid buffer overflows and whatnot.
I'm not saying you should be using statically allocated data for everything (quite the contrary usually), but for string buffers and such, a char buf[BUF_SIZE]; is usually good enough.

--- End quote ---
I know, but this applies in a context you can't control the length of the string. Here, the popup does not limit the number of characters entered, and at first it was a 256 buffer. Some people complained because it crashes when you enter a 120 chars string, and indeed ... the popup does not limit it. Thus, without having to allocate a 1024 buffer, I prefer using the dynamic length String API the Nspire uses. I think this API is the only one that runs really nicely compared to a lot of things on Nspire development.
On the other hand, there is a place in the OS where it limits the string length to 256 because the buffer is 256 : The SaveAs popup. And this has sense, I agree.

Matrefeytontias:
I'm using nspire_emu_easy from Ti-Planet, it's a version with Ndl3ss already in it. Do you think it could be the wrong version ?

And there is a SaveAs popup ? O.o I didn't see it.

Levak:

--- Quote from: Matrefeytontias on January 21, 2013, 02:14:59 pm ---I'm using nspire_emu_easy from Ti-Planet, it's a version with Ndl3ss already in it. Do you think it could be the wrong version ?

--- End quote ---
I've never heard of that before and I cannot find any archive having this name on TI-Planet.
But yeah, if Ndless is included in the archive, it is surely outdated. Ndless updates syscalls and developments tools in background a lot of times.


--- Quote ---And there is a SaveAs popup ? O.o I didn't see it.

--- End quote ---
Yes and No. It is a syscall I did not added to Ndless for the moment as it is part of nFrame, still under development.
If you really want it, pick it up from ThemeEditor sources.

hoffa:

--- Quote from: Matrefeytontias on January 21, 2013, 02:14:59 pm ---I'm using nspire_emu_easy from Ti-Planet, it's a version with Ndl3ss already in it. Do you think it could be the wrong version ?

--- End quote ---
I'm pretty sure that's the all-in-one nspire_emu package I made. I think it has an older version of Ndless installed (that did have some issues), so I suggest you download the newest Ndless, install it on the emulator, and save the flash image.

epic7:
Is there an ndless sdk/editor for linux?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version