Skip to content

Commit

Permalink
Allow the buffered objects to be something other than a pointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchisnall committed Jan 31, 2016
1 parent d0a290c commit 6bf87d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <stdlib.h>

#define BUFFER_SIZE 128
static BUFFER_TYPE *buffered_object_buffer[BUFFER_SIZE];
static BUFFER_TYPE **buffered_object_overflow;
static BUFFER_TYPE buffered_object_buffer[BUFFER_SIZE];
static BUFFER_TYPE *buffered_object_overflow;
static int buffered_objects;
static int buffered_object_overflow_space;

static void set_buffered_object_at_index(BUFFER_TYPE *cat, unsigned int i)
static void set_buffered_object_at_index(BUFFER_TYPE cat, unsigned int i)
{
if (i < BUFFER_SIZE)
{
Expand All @@ -23,20 +23,20 @@ static void set_buffered_object_at_index(BUFFER_TYPE *cat, unsigned int i)
if (NULL == buffered_object_overflow)
{
buffered_object_overflow =
calloc(BUFFER_SIZE, sizeof(BUFFER_TYPE*));
calloc(BUFFER_SIZE, sizeof(BUFFER_TYPE));
buffered_object_overflow_space = BUFFER_SIZE;
}
while (i >= buffered_object_overflow_space)
{
buffered_object_overflow_space <<= 1;
buffered_object_overflow = realloc(buffered_object_overflow,
buffered_object_overflow_space * sizeof(BUFFER_TYPE*));
buffered_object_overflow_space * sizeof(BUFFER_TYPE));
}
buffered_object_overflow[i] = cat;
}
}

static BUFFER_TYPE *buffered_object_at_index(unsigned int i)
static BUFFER_TYPE buffered_object_at_index(unsigned int i)
{
if (i<BUFFER_SIZE)
{
Expand All @@ -52,7 +52,7 @@ static void compact_buffer(void)
unsigned insert = 0;
for (unsigned i=0 ; i<size ; i++)
{
BUFFER_TYPE *c = buffered_object_at_index(i);
BUFFER_TYPE c = buffered_object_at_index(i);
if (c != NULL)
{
set_buffered_object_at_index(c, insert++);
Expand Down
2 changes: 1 addition & 1 deletion category_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "loader.h"
#include "dtable.h"

#define BUFFER_TYPE struct objc_category
#define BUFFER_TYPE struct objc_category *
#include "buffer.h"

void objc_send_load_message(Class class);
Expand Down
2 changes: 1 addition & 1 deletion protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "lock.h"
#include <stdlib.h>

#define BUFFER_TYPE struct objc_protocol_list
#define BUFFER_TYPE struct objc_protocol_list *
#include "buffer.h"

// Get the functions for string hashing
Expand Down
2 changes: 1 addition & 1 deletion statics_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "constant_string.h"
#include "visibility.h"

#define BUFFER_TYPE struct objc_static_instance_list
#define BUFFER_TYPE struct objc_static_instance_list *
#include "buffer.h"

static BOOL try_init_statics(struct objc_static_instance_list *statics)
Expand Down

0 comments on commit 6bf87d9

Please sign in to comment.