source: trunk/emx/src/emxomf/grow.h@ 3669

Last change on this file since 3669 was 3669, checked in by bird, 15 years ago

grow.h/c: Store the string length, speeds up collition handling and adds strpool_len() for skipping strlen()'s. Fixed strpool_addnu/strpool_addu matching bug.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.0 KB
Line 
1/* grow.h -- Growing arrays, growing buffers and string pools
2 Copyright (c) 1993-1995 Eberhard Mattes
3
4This file is part of emx.
5
6emx is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11emx is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with emx; see the file COPYING. If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
20
21
22#define GROW_INIT {0, 0, 0, 0, NULL}
23#define BUFFER_INIT {0, 0, NULL}
24
25struct grow
26{
27 int count;
28 int alloc;
29 int size;
30 int inc;
31 void **ptr;
32};
33
34struct buffer
35{
36 size_t size;
37 size_t alloc;
38 byte *buf;
39};
40
41/* Note: PTR is a pointer to a pointer */
42void grow_init (struct grow *g, void *ptr, size_t size, int inc);
43void grow_free (struct grow *g);
44void grow_to (struct grow *g, int new_count);
45void grow_by (struct grow *g, int inc);
46
47void buffer_init (struct buffer *b);
48void buffer_free (struct buffer *b);
49void buffer_byte (struct buffer *b, byte x);
50void buffer_word (struct buffer *b, word x);
51void buffer_dword (struct buffer *b, dword x);
52void buffer_mem (struct buffer *b, const void *mem, int len);
53void buffer_nstr (struct buffer *b, const char *str);
54void buffer_enc (struct buffer *b, const char *str);
55void buffer_patch_word (struct buffer *b, int index, word x);
56
57struct strpool *strpool_init (void);
58void strpool_free (struct strpool *p);
59const char *strpool_addn (struct strpool *p, const char *s, int len);
60const char *strpool_add (struct strpool *p, const char *s);
61const char *strpool_addnu (struct strpool *p, const char *s, int len);
62const char *strpool_addu (struct strpool *p, const char *s);
63int strpool_len (const char *s);
64
Note: See TracBrowser for help on using the repository browser.