Switch based on memory pointer type in C

Is there a way using C51/Cx51 to easily switch based on the memory type of a generic pointer? So far, the best thing I have is:

void my_func(void * ptr) {
  switch(*(uint8_t *)&ptr) {
    case 0x00:
      // do data/idata-specific stuff
    case 0x01:
      // do xdata-specific stuff
    case 0xff:
      // do code-specific stuff
    default:
      // do error-handling
  }
}

More questions in this forum