00001 /*************************************************************************** 00002 buffer.c 00003 ------------------- 00004 begin : Wed Nov 28 2001 00005 copyright : (C) 2001,2002 by Christian Hoenig & Gunter Ohrner 00006 email : pdepp@CustomCDROM.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00023 #include "common.h" 00024 00025 #include "buffer.h" 00026 #include "xmalloc.h" 00027 00028 // initializes a buffer and returns it 00029 struct Buffer bufInit(char* data, size_t len, size_t pos) 00030 { 00031 struct Buffer buf; 00032 buf.data = data; 00033 buf.len = len; 00034 buf.pos = pos; 00035 00036 return buf; 00037 } 00038 00039 //mallocs a buffer, initializes it and returns a pointer to it 00040 struct Buffer* bufpInit(char* data, size_t len, size_t pos) 00041 { 00042 struct Buffer* buf = (struct Buffer*) pd_malloc(sizeof(struct Buffer)); 00043 buf->data = data; 00044 buf->len = len; 00045 buf->pos = pos; 00046 00047 return buf; 00048 }