X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvector.c;h=5da797c0a0678fdf6abb3fc1683be6e502ea0a1b;hb=fa61f97cbbd1246c659d4d07b302c1a02cafcd97;hp=8d8e47067eedd7ad5a3dbb70917ea4e00a3ed646;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp-builds.git diff --git a/src/data/vector.c b/src/data/vector.c index 8d8e4706..5da797c0 100644 --- a/src/data/vector.c +++ b/src/data/vector.c @@ -1,35 +1,35 @@ -/* PSPP - computes sample statistics. - Copyright (C) 2006 Free Software Foundation, Inc. +/* PSPP - a program for statistical analysis. + Copyright (C) 2006, 2011 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ #include -#include "vector.h" -#include "dictionary.h" +#include "data/vector.h" -#include -#include +#include -#include "xalloc.h" +#include "data/dictionary.h" +#include "libpspp/assertion.h" +#include "libpspp/str.h" + +#include "gl/xalloc.h" /* Vector of variables. */ struct vector { - char name[LONG_NAME_LEN + 1]; /* Name. */ + char *name; /* Name. */ struct variable **vars; /* Set of variables. */ size_t var_cnt; /* Number of variables. */ }; @@ -57,7 +57,7 @@ vector_create (const char *name, assert (var_cnt > 0); assert (var_is_plausible_name (name, false)); - str_copy_trunc (vector->name, sizeof vector->name, name); + vector->name = xstrdup (name); vector->vars = xmemdup (vars, var_cnt * sizeof *vector->vars); vector->var_cnt = var_cnt; @@ -79,7 +79,7 @@ vector_clone (const struct vector *old, struct vector *new = xmalloc (sizeof *new); size_t i; - strcpy (new->name, old->name); + new->name = xstrdup (old->name); new->vars = xnmalloc (old->var_cnt, sizeof *new->vars); new->var_cnt = old->var_cnt; @@ -98,6 +98,7 @@ vector_clone (const struct vector *old, void vector_destroy (struct vector *vector) { + free (vector->name); free (vector->vars); free (vector); } @@ -110,7 +111,7 @@ vector_get_name (const struct vector *vector) } /* Returns the type of the variables in VECTOR. */ -enum var_type vector_get_type (const struct vector *vector) +enum val_type vector_get_type (const struct vector *vector) { return var_get_type (vector->vars[0]); }