Thread: C++ and MAME
View Single Post
Old 08-08-2014, 09:46 PM   #7
Kong's Avatar
 
Kong

Re: C++ and MAME

Like this?
Code:
void *updateSize(void* p, size_t OldLength, size_t NewLength) {
  void *p2 = malloc(NewLength);
  if(p2 == NULL) {
	return NULL;
  }
  if (p && p2) {
    memcpy(p2, p, OldLength < NewLength ? OldLength : NewLength);
  }
  if (p && (p2 || (NewLength == 0))) {
    free(p); 
  }
  return p2;
}
My SignatureDisplay Signature Reply With Quote