1 // vim: noet sw=4 ts=4:
3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2018-2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
23 Abstract: Alloc and free message buffers.
26 Author: E. Scott Daniels
29 #include "sisetup.h" // get the standard include stuff
32 Alloc a buffer with enough room for size bytes in the payload.
33 Returns a pointer to the payload portion of the buffer or NULL
34 if there is an error. Errno likely set to something meaningful
37 SIalloc_msg( int size ) {
47 need = size + sizeof( tp_hdr_t );
48 tp_buf = (tp_hdr_t *) alloc( sizeof( char ) * need );
50 memcpy( tp_buf->marker, "@!@!", 4 );
58 Free the message. We assume the user programme is calling and passing
59 a pointer to the payload portion which needs to be "backed up" to the
60 real buffer start to free.
62 SIfree_msg( void* vmsg ) {
65 if( (msg = (char *) vmsg) != NULL {
66 free( msg - sizeof( tp_hdr_t ) );