Revert "particle/list: optionally destroy sub particles"

This reverts commit c5d3e934b4.
This commit is contained in:
Daniel Eklöf 2018-11-17 22:43:11 +01:00
parent 5a155d1a8d
commit 6bd698fbc8
3 changed files with 5 additions and 16 deletions

View file

@ -166,8 +166,7 @@ particle_list_from_config(const struct yml_node *node,
}
struct particle *list = particle_list_new(
parts, count, left_spacing, right_spacing, left_margin, right_margin,
true);
parts, count, left_spacing, right_spacing, left_margin, right_margin);
free(parts);
return list;

View file

@ -5,7 +5,6 @@ struct particle_private {
struct particle **particles;
size_t count;
int left_spacing, right_spacing;
bool has_ownership;
};
struct exposable_private {
@ -94,12 +93,8 @@ static void
particle_destroy(struct particle *particle)
{
struct particle_private *p = particle->private;
if (p->has_ownership) {
for (size_t i = 0; i < p->count; i++)
p->particles[i]->destroy(p->particles[i]);
}
for (size_t i = 0; i < p->count; i++)
p->particles[i]->destroy(p->particles[i]);
free(p->particles);
free(p);
free(particle);
@ -108,15 +103,13 @@ particle_destroy(struct particle *particle)
struct particle *
particle_list_new(
struct particle *particles[], size_t count,
int left_spacing, int right_spacing, int left_margin, int right_margin,
bool take_ownership)
int left_spacing, int right_spacing, int left_margin, int right_margin)
{
struct particle_private *p = malloc(sizeof(*p));
p->particles = malloc(count * sizeof(p->particles[0]));
p->count = count;
p->left_spacing = left_spacing;
p->right_spacing = right_spacing;
p->has_ownership = take_ownership;
for (size_t i = 0; i < count; i++)
p->particles[i] = particles[i];

View file

@ -1,9 +1,6 @@
#pragma once
#include <stdbool.h>
#include "../particle.h"
struct particle *particle_list_new(
struct particle *particles[], size_t count,
int left_spacing, int right_spacing, int left_margin, int right_margin,
bool take_ownership);
int left_spacing, int right_spacing, int left_margin, int right_margin);