summaryrefslogtreecommitdiff
path: root/product.c
blob: 39a4e59c16e52792fbc26a3a278037c3e397361b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
#include "icclient/product.h"

void icclient_product_init(struct icclient_product *product)
{
	product->sku = NULL;
	product->description = NULL;
	product->comment = NULL;
	product->thumb = NULL;
	product->image = NULL;
	product->price = .0;
	product->prodgroup = NULL;
	product->weight = .0;
	product->author = NULL;
	product->crosssell = NULL;
}

void icclient_product_free(struct icclient_product *product)
{
	if (product->crosssell)
		for (size_t i = 0; i < product->crosssell->length; i++)
			free(product->crosssell->skus[i]);
	if (product->author)
		free(product->author);
	if (product->prodgroup)
		free(product->prodgroup);
	if (product->image)
		free(product->image);
	if (product->thumb)
		free(product->thumb);
	if (product->comment)
		free(product->comment);
	if (product->description)
		free(product->description);
	free(product->sku);
	free(product);
	product = NULL;
}