Skip to content

Plugin crash caused by deactivated functions provided in libplugin.h #61

@CoSoCo

Description

@CoSoCo

The use of the following functions in a plugin cause it to crash:

void jp_pref_init(prefType prefs[], int count);
void jp_free_prefs(prefType prefs[], int count);

This is, because their implementation in prefs.c was deactivated since JPilot version 2.0.2.
Please activate them again.

I also don't understand why the strings of the glob_prefs are initialised with the default values using the long switch ... case statement (from line 172 in prefs.c) are initialised with the default values instead of using the compact jp_pref_init() function. Take a look at how compactly I have solved this in JPilotMediaPlugin (from line 68) and line 945. It is also much more organised and clearer if the default strings are defined in the same assignment of the prefs array.

And they could be coded more compact :

void jp_pref_init(prefType prefs[], int count) {
   for (int i=0; i<count; i++) {
      prefs[i].svalue = strdup(prefs[i].svalue ? prefs[i].svalue : "");
      prefs[i].svalue_size = strlen(prefs[i].svalue)+1;
   }
}

void jp_free_prefs(prefType prefs[], int count) {
   for (int i=0; i<count; i++) {
      if (prefs[i].svalue) {
         free(prefs[i].svalue);
         prefs[i].svalue = NULL;
      }
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions