RFC 24: check if the parent pointer is NULL and raise an error otherwise */
| 2003 | RFC 24: check if the parent pointer is NULL and raise an error otherwise |
| 2004 | */ |
| 2005 | int msCheckParentPointer(void* p, char *objname) { |
| 2006 | char* fmt="The %s parent object is null"; |
| 2007 | char* msg=NULL; |
| 2008 | if (p == NULL) { |
| 2009 | if(objname != NULL) { |
| 2010 | msg=malloc( sizeof(char) * ( ( strlen(fmt)+strlen(objname) ) ) ); |
| 2011 | if(msg == NULL) { |
| 2012 | msg="A required parent object is null"; |
| 2013 | } else { |
| 2014 | sprintf(msg, "The %s parent object is null", objname); |
| 2015 | } |
| 2016 | } else { |
| 2017 | msg="A required parent object is null"; |
| 2018 | } |
| 2019 | msSetError(MS_NULLPARENTERR, msg, ""); |
| 2020 | return MS_FAILURE; |
| 2021 | } |
| 2022 | return MS_SUCCESS; |
| 2023 | } |
| 2024 | |
| 2025 | void msBufferInit(bufferObj *buffer) { |
| 2026 | buffer->data=NULL; |
no test coverage detected