|
|
1.1 ! root 1: /* ! 2: * Copyright (C) 2006-2009 Free Software Foundation ! 3: * ! 4: * This program is free software ; you can redistribute it and/or modify ! 5: * it under the terms of the GNU General Public License as published by ! 6: * the Free Software Foundation ; either version 2 of the License, or ! 7: * (at your option) any later version. ! 8: * ! 9: * This program is distributed in the hope that it will be useful, ! 10: * but WITHOUT ANY WARRANTY ; without even the implied warranty of ! 11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 12: * GNU General Public License for more details. ! 13: * ! 14: * You should have received a copy of the GNU General Public License ! 15: * along with the program ; if not, write to the Free Software ! 16: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! 17: */ ! 18: ! 19: #include <sys/types.h> ! 20: #include <string.h> ! 21: #include "ring.h" ! 22: ! 23: /* dest is ring */ ! 24: void hyp_ring_store(void *dest, const void *src, size_t size, void *start, void *end) ! 25: { ! 26: if (dest + size > end) { ! 27: size_t first_size = end - dest; ! 28: memcpy(dest, src, first_size); ! 29: src += first_size; ! 30: dest = start; ! 31: size -= first_size; ! 32: } ! 33: memcpy(dest, src, size); ! 34: } ! 35: ! 36: /* src is ring */ ! 37: void hyp_ring_fetch(void *dest, const void *src, size_t size, void *start, void *end) ! 38: { ! 39: if (src + size > end) { ! 40: size_t first_size = end - src; ! 41: memcpy(dest, src, first_size); ! 42: dest += first_size; ! 43: src = start; ! 44: size -= first_size; ! 45: } ! 46: memcpy(dest, src, size); ! 47: } ! 48: ! 49: size_t hyp_ring_next_word(char **c, void *start, void *end) ! 50: { ! 51: size_t n = 0; ! 52: ! 53: while (**c) { ! 54: n++; ! 55: if (++(*c) == end) ! 56: *c = start; ! 57: } ! 58: (*c)++; ! 59: ! 60: return n; ! 61: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.