Browse Source

* drop CALLOC() macro

master
Alex 'AdUser' Z 8 years ago
parent
commit
d692f9373c
  1. 6
      src/bitmap.c
  2. 7
      src/common.h
  3. 9
      src/database.c

6
src/bitmap.c

@ -81,7 +81,11 @@ simdb_bitmap_unpack(const unsigned char *map,
uint16_t *p, row, mask;
unsigned char *q = NULL;
CALLOC(*buf, buf_size, sizeof(char));
assert(map != NULL);
assert(buf != NULL);
if ((*buf = calloc(buf_size, sizeof(char))) == NULL)
return 0;
p = (uint16_t *) map;
q = *buf;

7
src/common.h

@ -19,13 +19,6 @@
#include <sys/stat.h>
#include <sys/types.h>
/** @defgroup MemoryMgmt Memory management macro
* @{*/
/** frees memory and sets pointer to zero */
#define FREE(ptr) \
free((ptr)); (ptr) = NULL;
/** allocates memory, and checks is it really allocated */
#define CALLOC(ptr, nmemb, size) \
assert(((ptr) = calloc((nmemb), (size))) != NULL);
/** @} */

9
src/database.c

@ -356,7 +356,8 @@ simdb_search(simdb_t * const db, int num,
if (search->maxdiff_ratio > 0.0)
ratio_s = simdb_record_ratio(&sample);
CALLOC(*matches, search->limit, sizeof(simdb_match_t));
if ((*matches = calloc(search->limit, sizeof(simdb_match_t))) == NULL)
return SIMDB_ERR_OOM;
for (num = 1; ; num += blksize) {
ret = simdb_read(db, num, blksize, &data);
@ -413,7 +414,8 @@ simdb_usage_map(simdb_t * const db, char ** const map) {
assert(map != NULL);
records = simdb_records_count(db);
CALLOC(m, records + 1, sizeof(char));
if ((m = calloc(records + 1, sizeof(char))) == NULL)
return SIMDB_ERR_OOM;
*map = m;
for (int num = 1; ; num += blksize) {
@ -451,7 +453,8 @@ simdb_usage_slice(simdb_t * const db, char ** const map, int offset, int limit)
if (ret <= 0)
return ret;
CALLOC(m, limit + 1, sizeof(char));
if ((m = calloc(limit + 1, sizeof(char))) == NULL)
return SIMDB_ERR_OOM;
m = *map;
r = data;

Loading…
Cancel
Save