static void open_section (AnjutaPluginDescriptionParser *parser, const char *name) { int n; if (parser->n_allocated_sections == parser->df->n_sections) grow_sections (parser); if (parser->current_section == 0 && parser->df->sections[0].section_name == 0 && parser->df->sections[0].n_lines == 0) { if (!name) g_warning ("non-initial NULL section\n"); /* The initial section was empty. Piggyback on it. */ parser->df->sections[0].section_name = g_quark_from_string (name); return; } n = parser->df->n_sections++; if (name) parser->df->sections[n].section_name = g_quark_from_string (name); else parser->df->sections[n].section_name = 0; parser->df->sections[n].n_lines = 0; parser->df->sections[n].lines = NULL; parser->current_section = n; parser->n_allocated_lines = 0; grow_lines (parser); }
static BusDesktopFileSection* new_section (BusDesktopFile *desktop_file, const char *name) { int n; char *name_copy; if (desktop_file->n_allocated_sections == desktop_file->n_sections) { if (!grow_sections (desktop_file)) return NULL; } name_copy = _dbus_strdup (name); if (name_copy == NULL) return NULL; n = desktop_file->n_sections; desktop_file->sections[n].section_name = name_copy; desktop_file->sections[n].n_lines = 0; desktop_file->sections[n].lines = NULL; desktop_file->sections[n].n_allocated_lines = 0; if (!grow_lines_in_section (&desktop_file->sections[n])) { dbus_free (desktop_file->sections[n].section_name); desktop_file->sections[n].section_name = NULL; return NULL; } desktop_file->n_sections += 1; return &desktop_file->sections[n]; }