GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
c_execmem.c
Go to the documentation of this file.
1/*!
2 \file cluster/c_execmem.c
3
4 \brief Cluster library - Allocate cluster
5
6 SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Original author CERL
10 */
11
12#include <grass/cluster.h>
13
14/*!
15 \brief Allocate Cluster structure
16
17 \param C pointer to Cluster structure
18
19 \return 1 on success
20 \return 0 on error
21 */
23{
24 G_debug(1, "I_cluster_exec_allocate(npoints=%d,nclasses=%d,nbands=%d)",
25 C->npoints, C->nclasses, C->nbands);
26
27 C->class = I_alloc_int(C->npoints);
29 C->count = I_alloc_int(C->nclasses);
35 if (C->class == NULL || C->reclass == NULL || C->sum == NULL ||
36 C->sumdiff == NULL || C->count == NULL || C->countdiff == NULL ||
37 C->sum2 == NULL || C->mean == NULL) {
39 return 0;
40 }
41 return 1;
42}
43
44/*!
45 \brief Free allocated Cluster structure
46
47 \param C pointer to Cluster structure
48
49 \return 0
50 */
52{
53 I_free(C->class);
54 I_free(C->reclass);
55 I_free(C->count);
56 I_free(C->countdiff);
61
62 C->class = NULL;
63 C->count = NULL;
64 C->countdiff = NULL;
65 C->sum = NULL;
66 C->sumdiff = NULL;
67 C->sum2 = NULL;
68 C->mean = NULL;
69
70 return 0;
71}
int I_cluster_exec_allocate(struct Cluster *C)
Allocate Cluster structure.
Definition c_execmem.c:22
int I_cluster_exec_free(struct Cluster *C)
Free allocated Cluster structure.
Definition c_execmem.c:51
#define NULL
Definition ccmath.h:32
int G_debug(int, const char *,...) __attribute__((format(printf
double ** I_alloc_double2(int, int)
int I_free_double2(double **)
int I_free(void *)
int * I_alloc_int(int)
int * count
Definition cluster.h:18
double ** sum2
Definition cluster.h:22
int npoints
Definition cluster.h:9
int * countdiff
Definition cluster.h:19
int * class
Definition cluster.h:16
int nclasses
Definition cluster.h:26
double ** mean
Definition cluster.h:23
int * reclass
Definition cluster.h:17
double ** sum
Definition cluster.h:20
int nbands
Definition cluster.h:8
double ** sumdiff
Definition cluster.h:21