Statistics
| Branch: | Revision:

grapes / som / ChunkBuffer / buffer-ha.c @ 8ab58ec7

History | View | Annotate | Download (503 Bytes)

1 8ab58ec7 Luca Abeni
/*
2
 *  Copyright (c) 2010 Luca Abeni
3
 *
4
 *  This is free software; see lgpl-2.1.txt
5
 */
6
7 87cee676 Luca Abeni
#include <stdlib.h>
8
#include <stdint.h>
9
#include <string.h>
10
11
#include "chunk.h"
12
#include "chunkbuffer.h"
13
14
const struct chunk *cb_get_chunk(const struct chunk_buffer *cb, int id)
15
{
16
  int i, n;
17
  const struct chunk *buffer;
18
19
  buffer = cb_get_chunks(cb, &n);
20
  if (buffer == NULL) {
21
    return NULL;
22
  }
23
24
  for (i = 0; i < n; i++) {
25
    if (buffer[i].id == id) {
26
      return &buffer[i];
27
    }
28
  }
29
30
  return NULL;
31
}