Make mv's use signed chars explicitly.
[xiph/unicode.git] / sushivision / function.c
blob2d4349516a16d2761a7e924b4998eb4cc48bd49e
1 /*
3 * sushivision copyright (C) 2006-2007 Monty <monty@xiph.org>
5 * sushivision is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * sushivision is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with sushivision; see the file COPYING. If not, write to the
17 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <errno.h>
26 #include "internal.h"
28 sv_func_t *sv_func_new(int number,
29 int out_vals,
30 void(*callback)(double *,double *),
31 unsigned flags){
32 sv_func_t *f;
34 if(number<0){
35 fprintf(stderr,"Function number must be >= 0\n");
36 errno = -EINVAL;
37 return NULL;
40 if(number<_sv_functions){
41 if(_sv_function_list[number]!=NULL){
42 fprintf(stderr,"Function number %d already exists\n",number);
43 errno = -EINVAL;
44 return NULL;
46 }else{
47 if(_sv_functions == 0){
48 _sv_function_list = calloc (number+1,sizeof(*_sv_function_list));
49 }else{
50 _sv_function_list = realloc (_sv_function_list,(number+1) * sizeof(*_sv_function_list));
51 memset(_sv_function_list + _sv_functions, 0, sizeof(*_sv_function_list)*(number +1 - _sv_functions));
53 _sv_functions=number+1;
56 f = _sv_function_list[number] = calloc(1, sizeof(**_sv_function_list));
57 f->number = number;
58 f->flags = flags;
59 f->callback = callback;
60 f->outputs = out_vals;
61 f->type = SV_FUNC_BASIC;
63 return f;