Changeset 39407
- Timestamp:
- Feb 26, 2016, 10:15:45 AM (10 years ago)
- Location:
- trunk/Ohana/src/libohana
- Files:
-
- 3 edited
-
include/ohana.h (modified) (1 diff)
-
src/ohana_allocate.c (modified) (7 diffs)
-
src/string.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libohana/include/ohana.h
r39248 r39407 239 239 # define myAssert(LOGIC,...) { if (!(LOGIC)) { fprintf (stderr, __VA_ARGS__); abort(); } } 240 240 # define myAbort(MSG) { fprintf (stderr, "%s\n", MSG); abort(); } 241 242 // a no-op to mark unused parameters in a function 243 # define OHANA_UNUSED_PARAM(x)(void)(x) 241 244 242 245 // sorting is now defined as a macro call -
trunk/Ohana/src/libohana/src/ohana_allocate.c
r39393 r39407 46 46 void *ohana_malloc (const char *file, int line, const char *func, size_t Nelem, size_t esize) { 47 47 48 void*ptr; // actual user memory allocated48 char *ptr; // actual user memory allocated 49 49 OhanaMemblock *new; // new memblock created to track the user memory 50 50 size_t size; // total number of bytes requested (not items) … … 144 144 // XXX for a test, we are going to always alloc a new block, copy the old data to the new block 145 145 // poison the old block, then free it 146 new = (OhanaMemblock *) malloc (sizeof(OhanaMemblock) + size + sizeof(void *));146 new = (OhanaMemblock *) malloc (sizeof(OhanaMemblock) + size + 2*sizeof(void *)); 147 147 if (new == NULL) ohana_memabort ("failed to reallocate memory (%s, %d, %s)\n", file, line, func); 148 void*ptr_new = (char *) (new + 1);149 void*ptr_old = (char *) (old + 1);148 char *ptr_new = (char *) (new + 1); 149 char *ptr_old = (char *) (old + 1); 150 150 size_t copy_bytes = old->size < size ? old->size : size; 151 151 memcpy (ptr_new, ptr_old, copy_bytes); … … 156 156 // ask for new memory 157 157 // total size is : memblock + data + endpost 158 new = (OhanaMemblock *) realloc (old, sizeof(OhanaMemblock) + size + sizeof(void *));158 new = (OhanaMemblock *) realloc (old, sizeof(OhanaMemblock) + size + 2*sizeof(void *)); 159 159 if (new == NULL) ohana_memabort ("failed to reallocate memory (%s, %d, %s)\n", file, line, func); 160 void*ptr_new = (char *) (new + 1);160 char *ptr_new = (char *) (new + 1); 161 161 # endif 162 162 … … 201 201 pthread_mutex_unlock(&memBlockListMutex); 202 202 203 return ( ptr_new);203 return (void *) ptr_new; 204 204 } 205 205 … … 268 268 269 269 // pointer to the start of the user memory 270 void*ptr = (char *)(ref + 1);270 char *ptr = (char *)(ref + 1); 271 271 memset (ptr, 0x7f, ref->size); 272 272 … … 285 285 286 286 int ohana_memcheck_noop (int allmemory) { 287 OHANA_UNUSED_PARAM(allmemory); 287 288 return TRUE; 288 289 } … … 521 522 522 523 OhanaMemstats ohana_memstats (int allmemory) { 524 OHANA_UNUSED_PARAM(allmemory); 523 525 524 526 OhanaMemstats memstats; -
trunk/Ohana/src/libohana/src/string.c
r39393 r39407 432 432 void uppercase (char *string) { 433 433 434 int i;434 unsigned int i; 435 435 436 436 for (i = 0; i < strlen (string); i++) string[i] = toupper (string[i]);
Note:
See TracChangeset
for help on using the changeset viewer.
