[Github-comments] [geany/geany] Modify/Extend Stash Settings API (PR #3000)

xiota notifications at xxxxx
Sun Nov 14 06:16:15 UTC 2021


Example of finding group and pref by name:
```C
StashGroup *group = stash_group_get_group_by_name("cup");
if (group) {
  StashPref *pref = stash_group_get_pref_by_name(group, "price");
  if (pref) {
    msgwin_status_add("%s.%s = %f", group->name, pref->key_name, *(gdouble *)pref->setting);
  } else {
    msgwin_status_add("pref not found");
  }
} else {
  msgwin_status_add("group not found");
}
```

Problem: Doesn't work if used after `stash_group_free()`.

In addition to reviewing memory management... Some potential solutions:
* Rewrite "free" to defer actual deallocation until Geany is being shutdown.  Pro: Minimize changes to existing code, maybe.  Con: "free" doesn't do what it says it will.
* Rewrite code to defer deallocation until Geany is being shutdown.  Pro: "free" does what it says it will.  Con: Probably will require extensive changes to existing code.
* Replace "free" with "free_later" (or some such).  Pro: "free" and "free_later" do what they say they will.  Just need to replace "free" with "free_later" in existing code.  Con: Use of "free" can still prevent the lookup from working.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3000#issuecomment-968214385
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211113/ccca8038/attachment.htm>


More information about the Github-comments mailing list