Changeset 31 for trunk/lib/smb_deps.c


Ignore:
Timestamp:
07/16/05 15:05:19 (19 years ago)
Author:
tim
Message:

Added new lightweight stack library

rewrote test program to use this instead of string concatenation/recursion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/smb_deps.c

    r30 r31  
    3333{
    3434  void* ret_val = NULL;
    35   if(ret_val = (void*)malloc(size))
     35  if((ret_val = (void*)malloc(size)) != NULL)
    3636    memset(ret_val, 0, size);
    3737  return ret_val;
     
    4242  return zalloc(size*count);
    4343}
    44 
    45 void zerop(void* p)
    46 {
    47   if(p)
    48     memset((char*)p, 0, sizeof(*p));
    49 }
    50 
    5144
    5245/* From lib/time.c */
     
    182175bool prs_init(prs_struct *ps, uint32 size, void *ctx, bool io)
    183176{
    184         zerop(ps);
    185         ps->io = io;
    186         ps->bigendian_data = RPC_LITTLE_ENDIAN;
    187         ps->align = RPC_PARSE_ALIGN;
    188         ps->is_dynamic = false;
    189         ps->data_offset = 0;
    190         ps->buffer_size = 0;
    191         ps->data_p = NULL;
    192         ps->mem_ctx = ctx;
    193 
    194         if (size != 0) {
    195                 ps->buffer_size = size;
    196                 if((ps->data_p = (char *)zalloc((size_t)size)) == NULL) {
    197                         return false;
    198                 }
    199                 memset(ps->data_p, '\0', (size_t)size);
    200                 ps->is_dynamic = true; /* We own this memory. */
    201         }
    202 
    203         return true;
     177  memset(ps, 0, sizeof(prs_struct));
     178  ps->io = io;
     179  ps->bigendian_data = RPC_LITTLE_ENDIAN;
     180  ps->align = RPC_PARSE_ALIGN;
     181  ps->is_dynamic = false;
     182  ps->data_offset = 0;
     183  ps->buffer_size = 0;
     184  ps->data_p = NULL;
     185  ps->mem_ctx = ctx;
     186 
     187  if (size != 0) {
     188    ps->buffer_size = size;
     189    if((ps->data_p = (char *)zalloc((size_t)size)) == NULL) {
     190      return false;
     191    }
     192    memset(ps->data_p, '\0', (size_t)size);
     193    ps->is_dynamic = true; /* We own this memory. */
     194  }
     195 
     196  return true;
    204197}
    205198
     
    529522 Compare the auth portion of two sids.
    530523*****************************************************************/ 
    531 static int sid_compare_auth(const DOM_SID *sid1, const DOM_SID *sid2)
     524int sid_compare_auth(const DOM_SID *sid1, const DOM_SID *sid2)
    532525{
    533526        int i;
Note: See TracChangeset for help on using the changeset viewer.