Statistics
| Branch: | Revision:

grapes / som / ChunkBuffer / buffer-ha.c @ cb201402

History | View | Annotate | Download (414 Bytes)

1
#include <stdlib.h>
2
#include <stdint.h>
3
#include <string.h>
4

    
5
#include "chunk.h"
6
#include "chunkbuffer.h"
7

    
8
const struct chunk *cb_get_chunk(const struct chunk_buffer *cb, int id)
9
{
10
  int i, n;
11
  const struct chunk *buffer;
12

    
13
  buffer = cb_get_chunks(cb, &n);
14
  if (buffer == NULL) {
15
    return NULL;
16
  }
17

    
18
  for (i = 0; i < n; i++) {
19
    if (buffer[i].id == id) {
20
      return &buffer[i];
21
    }
22
  }
23

    
24
  return NULL;
25
}