assert(v->size == allocations_len);
// free a few allocations out of order from that in which we allocated
- int r = vmfree(v, p[3]);
- assert(r == 0);
- r = vmfree(v, p[6]);
- assert(r == 0);
- r = vmfree(v, p[5]);
- assert(r == 0);
+ vmfree(v, p[3]);
+ vmfree(v, p[6]);
+ vmfree(v, p[5]);
// the allocator should have correctly stopped tracking those pointers
assert(v->size == allocations_len - 3);
// free the rest of the allocations in one sweep
- r = vmclear(v);
+ int r = vmclear(v);
assert(r == 0);
/* the allocator should have dropped all pointers it was tracking */
}
// discard this
- int r = vmfree(v, p);
- assert(r == 0);
+ vmfree(v, p);
// get a new pointer
p = vmalloc(v, s);
}
// clean up
- r = vmclose(v);
+ int r = vmclose(v);
assert(r == 0);
}
assert(strcmp(s, t) == 0);
// discard these strings
- int r = vmfree(v, s);
- assert(r == 0);
- r = vmfree(v, t);
- assert(r == 0);
+ vmfree(v, s);
+ vmfree(v, t);
/* vmstrdup does not assume the input string is mutable, so lets pass it a
* non-writable string
assert(strcmp(sc, t) == 0);
// clean up
- r = vmclose(v);
+ int r = vmclose(v);
assert(r == 0);
}
return p;
}
-int vmfree(Vmalloc_t *vm, void *data) {
+void vmfree(Vmalloc_t *vm, void *data) {
if (!data) { // ANSI-ism
- return 0;
+ return;
}
// find the pointer we previously allocated
// give this back to the underlying allocator
free(data);
- return 0;
+ return;
}
}
// we did not find this pointer; free() of something we did not allocate
- return -1;
}
void *vmresize(Vmalloc_t *vm, void *data, size_t size) {
*
* @param vm Region the pointer was originally allocated from
* @param data The pointer originally received from vmalloc
- * @returns 0 on success
*/
-int vmfree(Vmalloc_t *vm, void *data);
+void vmfree(Vmalloc_t *vm, void *data);
extern char *vmstrdup(Vmalloc_t *, const char *);