Mercurial > audlegacy-plugins
comparison src/shnplug/array.c @ 1305:51bf0e431e02
Add SHNplug.
| author | William Pitcock <nenolod@atheme-project.org> |
|---|---|
| date | Fri, 20 Jul 2007 10:29:54 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1300:c198ae31bb74 | 1305:51bf0e431e02 |
|---|---|
| 1 /****************************************************************************** | |
| 2 * * | |
| 3 * Copyright (C) 1992-1995 Tony Robinson * | |
| 4 * * | |
| 5 * See the file doc/LICENSE.shorten for conditions on distribution and usage * | |
| 6 * * | |
| 7 ******************************************************************************/ | |
| 8 | |
| 9 /* | |
| 10 * $Id: array.c,v 1.7 2003/08/26 05:34:04 jason Exp $ | |
| 11 */ | |
| 12 | |
| 13 #include <stdio.h> | |
| 14 #include <stdlib.h> | |
| 15 #include "shorten.h" | |
| 16 | |
| 17 void *pmalloc(ulong size, shn_file *this_shn) { | |
| 18 void *ptr; | |
| 19 | |
| 20 ptr = malloc(size); | |
| 21 | |
| 22 if(ptr == NULL) | |
| 23 shn_error_fatal(this_shn,"Call to malloc(%ld) failed in pmalloc() -\nyour system may be low on memory", size); | |
| 24 | |
| 25 return(ptr); | |
| 26 } | |
| 27 | |
| 28 slong **long2d(ulong n0, ulong n1, shn_file *this_shn) { | |
| 29 slong **array0 = NULL; | |
| 30 | |
| 31 if((array0 = (slong**) pmalloc((ulong) (n0 * sizeof(slong*) + | |
| 32 n0 * n1 * sizeof(slong)),this_shn)) != NULL ) { | |
| 33 slong *array1 = (slong*) (array0 + n0); | |
| 34 int i; | |
| 35 | |
| 36 for(i = 0; i < n0; i++) | |
| 37 array0[i] = array1 + i * n1; | |
| 38 } | |
| 39 return(array0); | |
| 40 } |
