LCOV - code coverage report
Current view: top level - basic - ring.h (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 2 2 100.0 %
Date: 2015-07-29 18:47:03 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
       2             : 
       3             : #pragma once
       4             : 
       5             : /***
       6             :   This file is part of systemd.
       7             : 
       8             :   Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
       9             : 
      10             :   systemd is free software; you can redistribute it and/or modify it
      11             :   under the terms of the GNU Lesser General Public License as published by
      12             :   the Free Software Foundation; either version 2.1 of the License, or
      13             :   (at your option) any later version.
      14             : 
      15             :   systemd is distributed in the hope that it will be useful, but
      16             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      18             :   Lesser General Public License for more details.
      19             : 
      20             :   You should have received a copy of the GNU Lesser General Public License
      21             :   along with systemd; If not, see <http://www.gnu.org/licenses/>.
      22             : ***/
      23             : 
      24             : 
      25             : typedef struct Ring Ring;
      26             : 
      27             : struct Ring {
      28             :         uint8_t *buf;           /* buffer or NULL */
      29             :         size_t size;            /* actual size of @buf */
      30             :         size_t start;           /* start position of ring */
      31             :         size_t used;            /* number of actually used bytes */
      32             : };
      33             : 
      34             : /* flush buffer so it is empty again */
      35             : void ring_flush(Ring *r);
      36             : 
      37             : /* flush buffer, free allocated data and reset to initial state */
      38             : void ring_clear(Ring *r);
      39             : 
      40             : /* get pointers to buffer data and their length */
      41             : size_t ring_peek(Ring *r, struct iovec *vec);
      42             : 
      43             : /* copy data into external linear buffer */
      44             : size_t ring_copy(Ring *r, void *buf, size_t size);
      45             : 
      46             : /* push data to the end of the buffer */
      47             : int ring_push(Ring *r, const void *u8, size_t size);
      48             : 
      49             : /* pull data from the front of the buffer */
      50             : void ring_pull(Ring *r, size_t size);
      51             : 
      52             : /* return size of occupied buffer in bytes */
      53        1018 : static inline size_t ring_get_size(Ring *r)
      54             : {
      55        1018 :         return r->used;
      56             : }

Generated by: LCOV version 1.11