@@ -109,22 +109,18 @@ char *
109
109
npy_string_arena_malloc (npy_string_arena * arena , npy_string_realloc_func r ,
110
110
size_t size )
111
111
{
112
- // one extra size_t to store the size of the allocation
113
- size_t string_storage_size = size + sizeof (size_t );
114
- // expand size to nearest multiple of 8 bytes to ensure 64 bit alignment
115
- string_storage_size += (8 - string_storage_size % 8 );
116
- if ((arena -> size - arena -> cursor ) <= string_storage_size ) {
112
+ if ((arena -> size - arena -> cursor ) <= size ) {
117
113
// realloc the buffer so there is enough room
118
114
// first guess is to double the size of the buffer
119
115
size_t newsize ;
120
116
if (arena -> size == 0 ) {
121
- newsize = string_storage_size ;
117
+ newsize = size ;
122
118
}
123
- else if (((2 * arena -> size ) - arena -> cursor ) > string_storage_size ) {
119
+ else if (((2 * arena -> size ) - arena -> cursor ) > size ) {
124
120
newsize = 2 * arena -> size ;
125
121
}
126
122
else {
127
- newsize = arena -> size + string_storage_size ;
123
+ newsize = arena -> size + size ;
128
124
}
129
125
if ((arena -> cursor + size ) >= newsize ) {
130
126
// doubling the current size isn't enough
@@ -139,10 +135,8 @@ npy_string_arena_malloc(npy_string_arena *arena, npy_string_realloc_func r,
139
135
arena -> buffer = newbuf ;
140
136
arena -> size = newsize ;
141
137
}
142
- size_t * size_loc = (size_t * )& arena -> buffer [arena -> cursor ];
143
- * size_loc = size ;
144
- char * ret = & arena -> buffer [arena -> cursor + sizeof (size_t )];
145
- arena -> cursor += string_storage_size ;
138
+ char * ret = & arena -> buffer [arena -> cursor ];
139
+ arena -> cursor += size ;
146
140
return ret ;
147
141
}
148
142
0 commit comments