Changeset 8a43f01 in mainline


Ignore:
Timestamp:
2023-11-25T19:02:24Z (5 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, topic/simplify-dev-export
Children:
84d29a2
Parents:
69935a8
Message:

tbarcfg_close() should clean up

Location:
uspace/lib/tbarcfg
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/tbarcfg/private/tbarcfg.h

    r69935a8 r8a43f01  
    6464};
    6565
    66 extern errno_t smenu_entry_create(tbarcfg_t *, sif_node_t *, const char *,
     66extern errno_t smenu_entry_new(tbarcfg_t *, sif_node_t *, const char *,
    6767    const char *);
     68extern void smenu_entry_delete(smenu_entry_t *);
    6869
    6970#endif
  • uspace/lib/tbarcfg/src/tbarcfg.c

    r69935a8 r8a43f01  
    101101                }
    102102
    103                 rc = smenu_entry_create(tbcfg, nentry, caption, cmd);
     103                rc = smenu_entry_new(tbcfg, nentry, caption, cmd);
    104104                if (rc != EOK)
    105105                        goto error;
     
    124124void tbarcfg_close(tbarcfg_t *tbcfg)
    125125{
     126        smenu_entry_t *entry;
     127
     128        entry = tbarcfg_smenu_first(tbcfg);
     129        while (entry != NULL) {
     130                smenu_entry_delete(entry);
     131                entry = tbarcfg_smenu_first(tbcfg);
     132        }
     133
    126134        (void)sif_close(tbcfg->repo);
     135        free(tbcfg);
    127136}
    128137
     
    255264}
    256265
    257 /** Create a start menu entry and append it to the start menu (internal).
     266/** Allocate a start menu entry and append it to the start menu (internal).
    258267 *
    259268 * This only creates the entry in memory, but does not update the repository.
     
    264273 * @param cmd Command to run
    265274 */
    266 errno_t smenu_entry_create(tbarcfg_t *smenu, sif_node_t *nentry,
     275errno_t smenu_entry_new(tbarcfg_t *smenu, sif_node_t *nentry,
    267276    const char *caption, const char *cmd)
    268277{
     
    305314}
    306315
     316/** Delete start menu entry.
     317 *
     318 * This only deletes the entry from, but does not update the
     319 * repository.
     320 *
     321 * @param entry Start menu entry
     322 */
     323void smenu_entry_delete(smenu_entry_t *entry)
     324{
     325        list_remove(&entry->lentries);
     326        free(entry->caption);
     327        free(entry->cmd);
     328        free(entry);
     329}
     330
    307331/** @}
    308332 */
Note: See TracChangeset for help on using the changeset viewer.