Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buffer size: 1922793
- AL_MAP_WRITE_BIT_SOFT al_callac in LoadData:
- time: 0.001339
- time: 0.001617
- time: 0.001432
- time: 0.001500
- time: 0.001506
- time: 0.001463
- time: 0.001530
- time: 0.001548
- time: 0.001493
- time: 0.001633
- AL_MAP_WRITE_BIT_SOFT, al_malloc in loadData
- time: 0.001363
- time: 0.001500
- time: 0.001330
- time: 0.001467
- time: 0.001407
- time: 0.001342
- time: 0.001315
- time: 0.001465
- time: 0.001292
- time: 0.001459
- time: 0.001332
- AL_MAP_WRITE_BIT_SOFT | AL_MAP_READ_BIT_SOFT, al_malloc in loadData
- (eg. no memset on alBuffer data)
- time: 0.001097
- time: 0.000937
- time: 0.001005
- time: 0.000942
- time: 0.000984
- time: 0.001031
- time: 0.000946
- time: 0.000953
- time: 0.000939
- time: 0.001106
- // I still initialized the unreachable memory
- // but that's like 15 bytes max
- // was 7 in this test
- alBuffer.c: 1090
- - newsize = (newsize+15) & ~0xf;
- - if(newsize != ALBuf->BytesAlloc)
- - {
- - void *temp = al_calloc(16, (size_t)newsize);
- - if(!temp && newsize)
- - {
- - WriteUnlock(&ALBuf->lock);
- - return AL_OUT_OF_MEMORY;
- - }
- - al_free(ALBuf->data);
- - ALBuf->data = temp;
- - ALBuf->BytesAlloc = (ALuint)newsize;
- - }
- + const ALuint64 paddedNewSize = (newsize+15) & ~0xf;
- + if(paddedNewSize != ALBuf->BytesAlloc)
- + {
- + void *temp = al_malloc(16, (size_t)paddedNewSize);
- + if(!temp && paddedNewSize)
- + {
- + WriteUnlock(&ALBuf->lock);
- + return AL_OUT_OF_MEMORY;
- + }
- +
- + memset(temp + newsize, 0, paddedNewSize - newsize);
- +
- + al_free(ALBuf->data);
- + ALBuf->data = temp;
- + ALBuf->BytesAlloc = (ALuint)paddedNewSize;
- + }
- btw, if(newsize != ALBuf->BytesAlloc) returns false in the original
- you will get buffer with its old memory, which kind of invalidates
- the idea of getting zeroed memory.
- suggestion
- add AL_NO_MEMORY_INIT_BIT_SOFT, that will ensure, that no memset is
- performed on the alBuffer memory.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement