Major refactoring. Major problems!
On the right path but it doesn't work yet.
This commit is contained in:
parent
ae8ba67ed7
commit
9937f344dc
20 changed files with 695 additions and 506 deletions
|
|
@ -8,6 +8,7 @@
|
|||
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -29,7 +30,7 @@
|
|||
* NOTE that `tag` should be the vector-space tag of the particular type of
|
||||
* vector-space object, NOT `VECTORPOINTTAG`.
|
||||
*/
|
||||
struct cons_pointer make_vec_pointer( char *tag, uint64_t address ) {
|
||||
struct cons_pointer make_vec_pointer( char * tag, struct vector_space_object * address ) {
|
||||
struct cons_pointer pointer = allocate_cell( VECTORPOINTTAG );
|
||||
struct cons_space_object cell = pointer2cell( pointer );
|
||||
|
||||
|
|
@ -44,26 +45,33 @@ struct cons_pointer make_vec_pointer( char *tag, uint64_t address ) {
|
|||
* and return a `cons_pointer` which points to an object whigh points to it.
|
||||
* NOTE that `tag` should be the vector-space tag of the particular type of
|
||||
* vector-space object, NOT `VECTORPOINTTAG`.
|
||||
* Returns NIL if the vector could not be allocated due to memory exhaustion.
|
||||
*/
|
||||
struct cons_pointer make_vso( char *tag, int64_t payload_size ) {
|
||||
struct cons_pointer make_vso( char *tag, uint64_t payload_size ) {
|
||||
struct cons_pointer result = NIL;
|
||||
int64_t total_size = sizeof( struct vector_space_header ) + payload_size;
|
||||
|
||||
struct vector_space_header *vso = malloc( total_size );
|
||||
/* Pad size to 64 bit words. This is intended to promote access efficiancy
|
||||
* on 64 bit machines but may just be voodoo coding */
|
||||
uint64_t padded = ceil((total_size * 8.0) / 8.0);
|
||||
struct vector_space_object *vso = malloc( padded );
|
||||
|
||||
if ( vso != NULL ) {
|
||||
strncpy( &vso->tag.bytes[0], tag, TAGLENGTH );
|
||||
vso->vecp = make_vec_pointer( tag, ( uint64_t ) vso );
|
||||
vso->size = payload_size;
|
||||
strncpy( &vso->header.tag.bytes[0], tag, TAGLENGTH );
|
||||
vso->header.vecp = make_vec_pointer( tag, vso );
|
||||
vso->header.size = payload_size;
|
||||
|
||||
#ifdef DEBUG
|
||||
fwprintf( stderr,
|
||||
L"Allocated vector-space object of type %s, total size %ld, payload size %ld\n",
|
||||
L"Allocated vector-space object of type %4.4s, total size %ld, payload size %ld\n",
|
||||
tag, total_size, payload_size );
|
||||
if (padded != total_size){
|
||||
fwprintf(stderr, L"\t\tPadded from %d to %d\n",
|
||||
total_size, padded);
|
||||
}
|
||||
#endif
|
||||
|
||||
result = vso->vecp;
|
||||
result = vso->header.vecp;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue