Selaa lähdekoodia

Removing obsolete files.

tags/v0.9.3
Michael Brown 17 vuotta sitten
vanhempi
commit
15f8323055
3 muutettua tiedostoa jossa 0 lisäystä ja 149 poistoa
  1. 0
    80
      src/core/ebuffer.c
  2. 0
    15
      src/include/gpxe/ebuffer.h
  3. 0
    54
      src/tests/buffertest.c

+ 0
- 80
src/core/ebuffer.c Näytä tiedosto

@@ -1,80 +0,0 @@
1
-/*
2
- * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License as
6
- * published by the Free Software Foundation; either version 2 of the
7
- * License, or any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
- * General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program; if not, write to the Free Software
16
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
- */
18
-
19
-/**
20
- * @file
21
- *
22
- * Automatically expanding buffers
23
- *
24
- */
25
-
26
-#include <errno.h>
27
-#include <gpxe/buffer.h>
28
-#include <gpxe/umalloc.h>
29
-#include <gpxe/ebuffer.h>
30
-
31
-/**
32
- * Expand expandable buffer
33
- *
34
- * @v buffer		Buffer descriptor
35
- * @v new_len		Required new size
36
- * @ret rc		Return status code
37
- */
38
-static int ebuffer_expand ( struct buffer *buffer, size_t new_len ) {
39
-	size_t actual_len = 1;
40
-	userptr_t new_addr;
41
-
42
-	/* Round new_len up to the nearest power of two, to reduce
43
-	 * total number of reallocations required.  Don't do this for
44
-	 * the first expansion; this allows for protocols that do
45
-	 * actually know the exact length in advance.
46
-	 */
47
-	if ( buffer->len ) {
48
-		while ( actual_len < new_len )
49
-			actual_len <<= 1;
50
-	} else {
51
-		actual_len = new_len;
52
-	}
53
-
54
-	/* Reallocate buffer */
55
-#warning "urealloc() has issues with length zero"
56
-	new_addr = urealloc ( buffer->addr, // actual_len );
57
-			      actual_len ? actual_len : 1 );
58
-	if ( ! new_addr )
59
-		return -ENOMEM;
60
-
61
-	buffer->addr = new_addr;
62
-	buffer->len = actual_len;
63
-	return 0;
64
-}
65
-
66
-/**
67
- * Allocate expandable buffer
68
- *
69
- * @v buffer		Buffer descriptor
70
- * @v len		Initial length (may be zero)
71
- * @ret rc		Return status code
72
- *
73
- * Allocates space for the buffer and stores it in @c buffer->addr.
74
- * The space must eventually be freed by calling ufree(buffer->addr).
75
- */
76
-int ebuffer_alloc ( struct buffer *buffer, size_t len ) {
77
-	memset ( buffer, 0, sizeof ( *buffer ) );
78
-	buffer->expand = ebuffer_expand;
79
-	return ebuffer_expand ( buffer, len );
80
-}

+ 0
- 15
src/include/gpxe/ebuffer.h Näytä tiedosto

@@ -1,15 +0,0 @@
1
-#ifndef _GPXE_EBUFFER_H
2
-#define _GPXE_EBUFFER_H
3
-
4
-/**
5
- * @file
6
- *
7
- * Automatically expanding buffers
8
- *
9
- */
10
-
11
-struct buffer;
12
-
13
-extern int ebuffer_alloc ( struct buffer *buffer, size_t len );
14
-
15
-#endif /* _GPXE_EBUFFER_H */

+ 0
- 54
src/tests/buffertest.c Näytä tiedosto

@@ -1,54 +0,0 @@
1
-#include <assert.h>
2
-#include <gpxe/buffer.h>
3
-
4
-
5
-struct buffer_test {
6
-	struct buffer buffer;
7
-	const char *source;
8
-	size_t source_len;
9
-	char *dest;
10
-	size_t dest_len;
11
-};
12
-
13
-static int test_fill_buffer ( struct buffer_test *test,
14
-			      size_t start, size_t end ) {
15
-	const void *data = ( test->source + start );
16
-	size_t len = ( end - start );
17
-
18
-	assert ( end <= test->source_len );
19
-	assert ( end <= test->dest_len );
20
-
21
-	fill_buffer ( &test->buffer, data, start, len );
22
-	assert ( memcmp ( ( test->dest + start ), data, len ) == 0 );
23
-	assert ( test->buffer.free >= end );
24
-	return 0;
25
-}
26
-
27
-int test_buffer ( void ) {
28
-	char source[123];
29
-	char dest[123];
30
-	struct buffer_test test;
31
-
32
-	memset ( &test, 0, sizeof ( test ) );
33
-	test.source = source;
34
-	test.source_len = sizeof ( source );
35
-	test.dest = dest;
36
-	test.dest_len = sizeof ( dest );
37
-	test.buffer.addr = virt_to_user ( dest );
38
-	test.buffer.len = sizeof ( dest );
39
-
40
-	test_fill_buffer ( &test,  20,  38 );
41
-	test_fill_buffer ( &test,  60,  61 );
42
-	test_fill_buffer ( &test,  38,  42 );
43
-	test_fill_buffer ( &test,  42,  60 );
44
-	test_fill_buffer ( &test,  16,  80 );
45
-	test_fill_buffer ( &test,   0,  16 );
46
-	test_fill_buffer ( &test,  99, 123 );
47
-	test_fill_buffer ( &test,  80,  99 );
48
-
49
-	assert ( test.buffer.fill == sizeof ( source ) );
50
-	assert ( test.buffer.free == sizeof ( source ) );
51
-	assert ( memcmp ( source, dest, sizeof ( source ) ) == 0 );
52
-
53
-	return 0;
54
-}

Loading…
Peruuta
Tallenna