⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wbuffalloc.c

📁 su 的源代码库
💻 C
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       *//* WBUFFALLOC: $Revision: 1.2 $ ; $Date: 1997/01/10 18:39:58 $	*//*********************** self documentation **********************//*************************************************************************WBUFFALLOC -  routines to allocate/initialize and free buffers in wavelet		packet compresson codesbuffAlloc1 - allocate a 1D  buffer of size n and initializebuffRealloc1 - reallocate a 1D buffer of size to n and set the position 		to end of buffer if n is less than buff->pos buffFree1 - free a 1D bufferbuffAlloc2 - allocate an array[n1] of buffers each with size n2 and initializebuffFree2 - free a 2d buffer*************************************************************************Function Prototypes:void *buffAlloc1(int n);void buffRealloc1(void *inbuff, int n);void buffFree1(void *inbuff);void **buffAlloc2(int n1, int n2);void buffFree2(void **inbuff, int n1)*************************************************************************buffAlloc1:Input:n		size of bufferReturns:(void *)buffbuffRealloc1:inbuff		input buffern		size of input bufferbuffFree1:Input:inbuff		buffer to be freedbuffAlloc2:Input:n1		buffer size in fast dimensionn2		buffer size in slow dimension*************************************************************************Author:  CWP: Tong Chen, 1995*************************************************************************//**************** end self doc ********************************/#include "wpc1.h"#include "wpc1lib.h"void *buffAlloc1(int n)/*************************************************************************allocate a 1D  buffer of size n and initialize*************************************************************************/{	wpcBUFF *buff;	buff = (wpcBUFF *) malloc(sizeof(wpcBUFF));	buff->code = (unsigned char *) malloc(n*sizeof(char));	/* init the position and bound */	buff->mbound = n;	buff->pos = 0;	return ((void *)buff);}void buffRealloc1(void *inbuff, int n)/*************************************************************************reallocate a 1D buffer of size to n and set the position to end of bufferif n is less than buff->pos *************************************************************************/{	wpcBUFF *buff = (wpcBUFF *) inbuff;	unsigned char *code;		code = buff->code;	buff->code = (unsigned char *) realloc(code, n*sizeof(char));	/* modify the bound */	buff->mbound = n;	buff->pos = (buff->pos > n)? n : buff->pos;}void buffFree1(void *inbuff)/*************************************************************************free a 1D buffer*************************************************************************/{	wpcBUFF *buff = (wpcBUFF *) inbuff;	free((void *) buff->code);	free((void *) buff);}void **buffAlloc2(int n1, int n2)/*************************************************************************allocate an array[n1] of buffers each with size n2 and initialize*************************************************************************/{	wpcBUFF **buff;	int i;	buff = (wpcBUFF **) malloc(n1*sizeof(wpcBUFF *));	/* the buffers do not have to be consective */	for(i=0; i<n1; i++) 	    buff[i] = (wpcBUFF *) buffAlloc1(n2);	return ((void **)buff);}void buffFree2(void **inbuff, int n1)/*************************************************************************free a 2D buffer*************************************************************************/{	wpcBUFF **buff = (wpcBUFF **) inbuff;	int i;	for(i=0; i<n1; i++)	    buffFree1((void *) buff[i]);		free((void **) buff);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -