Sigrid Haflínudóttirfirst dirty version of the portd7ad0686 years agoHistory
121 lines · 2.0 KB · C
RawDownload
/*	PBUFSTDC.h 	Copyright (C) 2018 Paul C. Pratt 	You can redistribute this file and/or modify it under the terms	of version 2 of the GNU General Public License as published by	the Free Software Foundation.  You should have received a copy	of the license along with this file; see the file COPYING. 	This file 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	license for more details.*/ /*	Parameter BUFfers implemented with STanDard C library*/  #if IncludePbufsLOCALVAR void *PbufDat[NumPbufs];#endif #if IncludePbufsLOCALFUNC tMacErr PbufNewFromPtr(void *p, ui5b count, tPbuf *r){	tPbuf i;	tMacErr err; 	if (! FirstFreePbuf(&i)) {		free(p);		err = mnvm_miscErr;	} else {		*r = i;		PbufDat[i] = p;		PbufNewNotify(i, count);		err = mnvm_noErr;	} 	return err;}#endif #if IncludePbufsLOCALPROC PbufKillToPtr(void **p, ui5r *count, tPbuf r){	*p = PbufDat[r];	*count = PbufSize[r]; 	PbufDisposeNotify(r);}#endif #if IncludePbufsGLOBALOSGLUFUNC tMacErr PbufNew(ui5b count, tPbuf *r){	tMacErr err = mnvm_miscErr; 	void *p = calloc(1, count);	if (NULL != p) {		err = PbufNewFromPtr(p, count, r);	} 	return err;}#endif #if IncludePbufsGLOBALOSGLUPROC PbufDispose(tPbuf i){	void *p;	ui5r count; 	PbufKillToPtr(&p, &count, i); 	free(p);}#endif #if IncludePbufsLOCALPROC UnInitPbufs(void){	tPbuf i; 	for (i = 0; i < NumPbufs; ++i) {		if (PbufIsAllocated(i)) {			PbufDispose(i);		}	}}#endif #if IncludePbufs#define PbufHaveLock 1#endif #if IncludePbufsLOCALFUNC ui3p PbufLock(tPbuf i){	return (ui3p)PbufDat[i];}#endif #if IncludePbufs#define PbufUnlock(i)#endif #if IncludePbufsGLOBALOSGLUPROC PbufTransfer(ui3p Buffer,	tPbuf i, ui5r offset, ui5r count, blnr IsWrite){	void *p = ((ui3p)PbufDat[i]) + offset;	if (IsWrite) {		(void) memcpy(p, Buffer, count);	} else {		(void) memcpy(Buffer, p, count);	}}#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t