Skip to content

Commit

Permalink
buf.h now uses size_t for array sizes.
Browse files Browse the repository at this point in the history
  • Loading branch information
skaslev committed Oct 19, 2016
1 parent abae92f commit d94f665
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions buf.c
@@ -1,8 +1,8 @@
#include "buf.h"

void buf_do_realloc_(void **a, int nr, int sz)
void buf_do_realloc_(void **a, size_t nr, size_t sz)
{
int *p = realloc(*a ? buf_raw_(*a) : NULL, 2 * sizeof(int) + nr * sz);
size_t *p = realloc(*a ? buf_raw_(*a) : NULL, 2 * sizeof(size_t) + nr * sz);
p[0] = nr;
if (!*a)
p[1] = 0;
Expand Down
4 changes: 2 additions & 2 deletions buf.h
Expand Up @@ -14,7 +14,7 @@
#define buf_foreach(it, a) for ((it) = (a); (it) < (a) + buf_len(a); (it)++)

/* Private */
#define buf_raw_(a) ((int *) (a) - 2)
#define buf_raw_(a) ((size_t *) (a) - 2)
#define buf_m_(a) (buf_raw_(a)[0])
#define buf_n_(a) (buf_raw_(a)[1])

Expand All @@ -23,6 +23,6 @@
buf_n_(a) == buf_m_(a) ? buf_realloc_(a, 2 * buf_m_(a)) : (void) 0)
#define buf_realloc_(a, n) buf_do_realloc_((void **) &(a), n, sizeof(*(a)))

void buf_do_realloc_(void **a, int nr, int sz);
void buf_do_realloc_(void **a, size_t nr, size_t sz);

#endif

0 comments on commit d94f665

Please sign in to comment.